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
 General SQL Server Forums
 New to SQL Server Programming
 Select distinct top row

Author  Topic 

obsoletedude
Starting Member

31 Posts

Posted - 2009-05-12 : 10:52:54
I have a table with the following two columns:
ClientID, ClientNo

In it would be a value structure like:
1 1
2 2
3 2
4 2
5 3
6 3
7 4

What I need to do is get the top ClientID from the disctinct ClientNo, so my results would be:
1 1
2 2
5 3
6 4

Any ideas would be very helpful.

Thank you.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-12 : 10:55:17
select min(ClientId) as ClientId, ClientNo from your_table
Group by ClientNo

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -