Selct DISTINCT

From: <trpost_at_gmail.com>
Date: Tue, 29 Jan 2008 10:33:31 -0800 (PST)
Message-ID: <4a2448ce-7fe8-4b58-b4c8-5d150e8b4b9e@i29g2000prf.googlegroups.com>


I am looking to query the first occurance of a row based on a distinct column. Here is an example result set:

SELECT * FROM TABLE ID Name SSN
456 Todd 1235
955 Jane 2345
955 Jane
988 Jack 3547

If I do this I get the expected number of results: SELECT DISTINCT(ID) FROM TABLE; ID
456
955
988

However if I do this I get all rows despite the distinct keyword: SELECT DISTINCT(ID), Name, SSN FROM TABLE;

ID Name SSN
456 Todd 1235
955 Jane 2345
955 Jane
988 Jack 3547

So it looks like distinct works on the row, looking for an entirely distinct row. What I want to do is look only at one column and return the first row occurance.

How can this be done? I am using an Oracle 10G database.

Thanks! Received on Tue Jan 29 2008 - 12:33:31 CST

Original text of this message