Forum Moderators: open

Message Too Old, No Replies

Trying to get distinct data + another column of data

distinct data exclude

         

sporb

12:55 am on May 22, 2008 (gmt 0)

10+ Year Member



I am trying to get distinct data, which is no problem, but then I need another column of data that will screw up my distinct data if the column is part of the select. so i need to exclude the column from the distinct?

to clarify things a bit here is my table.

a, b, c, extra
---------------
1,2,1,this
1,2,1,that
2,2,2,this
3,3,1,this
4,4,2,this

if i do a SELECT DISTINCT a FROM table
then i get the data i need, but i also need the data in extra
if i do SELECT DISTINCT a,extra from table
then the data in extra screws it up.

i only need to search column a for distinct values, but need the data from all the columns.

hope you get the idea.

coopster

12:15 am on May 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The data is not distinct. Well, it is distinct, but not complete for the result set you desire. So true, this is distinct:
1 this 
2 this
3 this
4 this

And this is distinct:
1 this 
1 that
2 this
3 this
4 this

So both are true, both return distinct lists.

How would you like the data to come back? What is the desired result?

sporb

7:33 pm on May 24, 2008 (gmt 0)

10+ Year Member



the date i want to come back would be

a, b, c, extra
---------------
1,2,1,this
2,2,2,this
3,3,1,this
4,4,2,this