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 2005 Forums
 Transact-SQL (2005)
 New Please Help

Author  Topic 

Maharisi
Starting Member

19 Posts

Posted - 2008-11-05 : 02:59:04
Posted - 11/05/2008 : 02:42:33
I have TABLE
ID Count Centre
================
1 5 RO
1 6 TO
2 4 JO
2 5 ZO

I need acquire row with Minimal Count for each ID.
Thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-05 : 03:01:59
[code]SELECT t1.*
FROM Table t1
INNER JOIN (SELECT ID,MIN(Count) AS MinCount
FROM Table
GROUP BY ID) t2
ON t2.ID=t1.ID
AND t2.MinCount=t1.Count[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-05 : 03:03:11
or if sql 2005

SELECT ID,Count,Centre
FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY ID ORDER BY Count) AS Seq,*
FROM Table
)t
WHERE t.Seq=1
Go to Top of Page
   

- Advertisement -