![]() | |
#1
| |||
| |||
|
#2
| |||||||
| |||||||
|
|
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! |
#3
| |||||||
| |||||||
|
|
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! |
#4
| |||||||
| |||||||
|
|
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! |
#5
| |||||||
| |||||||
|
|
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! |
#6
| ||||
| ||||
|
|
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! |
#7
| ||||
| ||||
|
|
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! |
#8
| ||||
| ||||
|
|
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! |
#9
| ||||
| ||||
|
|
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! |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |