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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select distinct row 1

Status
Not open for further replies.

bangalibhai

Programmer
Oct 22, 2002
26
US
token time store
==================================
4940 1/27/03 2:31 PM 2012
4940 1/27/03 2:33 PM 2012
4941 1/27/03 2:33 PM 2110
4942 1/27/03 2:34 PM 2126
4943 1/27/03 2:37 PM 2012
4944 1/27/03 2:37 PM 2389
4945 1/27/03 2:39 PM 2389
4946 1/27/03 2:39 PM 2012
4947 1/27/03 2:40 PM 2413
4948 1/27/03 2:41 PM 2506
4949 1/27/03 2:45 PM 2506
4949 1/27/03 3:03 PM 2127
4949 1/27/03 2:50 PM 2127
4950 1/27/03 2:50 PM 2459
4950 1/27/03 2:52 PM 2459
4950 1/27/03 2:46 PM 2459

Suppose I have the above table. I am trying to select unique instance of token including the entire row. For example there are three 4950 token. I need to to select the first row with 4950. The result would be as follows:

4950 1/27/03 2:50 PM 2459

I have done this before, but I have forgotten. Your help is greatly appreaciated.

Thanks,
Nihad
 
select * from t tq
where time =
(select select min(time)
from t
where token = tq.token )

 
Getting all of the data from the "first" row is somewhat of a problem. If your DBMS supports the TOP nn syntax, you could use
Code:
  SELECT TOP 1 * from t
  WHERE Token = 4950
  ORDER BY [Time]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top