Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL DISTINCT

Author  Topic 

CyberSquealer
Starting Member

11 Posts

Posted - 2011-10-07 : 10:18:51

I have a table structure similar to

Col1 Col2

123ABC 13:53:32
123ABC 13:55:25
123ABC 13:59:43
789XYZ 14:14:23
789XYZ 14:14:23
789XYZ 14:14:23


If I were to

Select Distinct Col1 from table1

I get all rows returned because the values are different in Col2

How can I only return the first instance of the value(123) in column 1 skipping the same values until I get to the next different value (789XYZ)

Many thanks

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2011-10-07 : 10:23:56
select col1, min(col2) from mytable group by col1
Go to Top of Page

CyberSquealer
Starting Member

11 Posts

Posted - 2011-10-07 : 10:48:42


A slightly different way of looking at problem!

Many thanks
Go to Top of Page
   

- Advertisement -