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 2008 Forums
 Transact-SQL (2008)
 min group by

Author  Topic 

lah1308
Starting Member

3 Posts

Posted - 2010-08-26 : 05:49:39
My data is as below and I basically want to select the MIN sequence by user, and want the data returned in the second set

User Item Reason Status Sequence
159695 C 2 8 3
159703 A 1 7 1
159703 B 3 5 2
159703 C 2 8 3
159725 C 2 8 3

User Item Reason Status Sequence
159695 C 2 8 3
159703 A 1 7 1
159725 C 2 8 3

Any help would be appreciated

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-08-26 : 06:23:48
[code]
select *
from
(
select *, row_no = row_number() over (partition by User order by Sequence)
from yourtable
) d
where d.row_no = 1
[/code]

KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -