From: | Fran Fabrizio <ffabrizio(at)mmrd(dot)com> |
---|---|
To: | "Peter E(dot) Chen" <pchen3(at)jhmi(dot)edu>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Quick SQL question . . . |
Date: | 2002-05-09 19:54:33 |
Message-ID: | 3CDAD3F9.90702@mmrd.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Perhaps a little on the hacky side but....
select count(1) from some_table group by identno order by 1 desc limit 1;
If the result is anything other than 1, it's not unique.
Sorry for the hacky nature, this is the "thought about it for 10
seconds" version. :-)
-Fran
Peter E. Chen wrote:
>Can anyone tell me what is the easiest way for me to tell if a column is
>unique or not? I tried using DISTINCT ON and COUNT together in a SELECT
>statement, but I can't seem to get the query to work:
>
>SELECT DISTINCT ON (identno) count(identno) FROM some_table;
>
>I was trying to figure out if the # of unique entries for a particular
>column is equal to the # of total entries for that column.
>
>Any suggestions?
>
>Peter
>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Marie G. Tuite | 2002-05-09 20:04:33 | Re: Quick SQL question . . . |
Previous Message | Peter E. Chen | 2002-05-09 19:39:18 | Quick SQL question . . . |