Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select distinct question?

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
0
0
US
I have a sql question... Here is the sql statement I currently have:
SELECT DISTINCT Gate.Name, Gate.Organization, Gate.PlateNum, Gate.PlateState, Gate.REC_ID FROM Gate;

REC_ID is a random number generated for easier record reference...

What happens when I use this statement, it returns all rows from the table because REC_ID is different in every record...

I need it to return the distinct for each row, then get the REC_ID that applies to the specified row... There is more data for times and date info in the table as well, but I don't include that in the sql because I don't need that at the time in the app...

Any idea's or questions for clairifacation, feel free to send me a note...

Thanks!

--James
Junior1544@jmjpc.net

junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Distinct really works best on one field. For instance, in your sample, a distinct Gate.Organization will be still show multiple entries for the same organization if the Gate.Name fields are different.
 
Yes... But then how do I get it to return the other fields as well?? I need a table returned to my app that has those different fields... Even if just the name is the distinct??

Thanks.
--James

junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
You may want to ask this question in the SQL forum here on Tek-Tips. The guys over there are pretty good.

Rob

Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Eisenhower 1953
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top