Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Posted - 11/05/2008 : 02:42:33 I have TABLEID Count Centre================1 5 RO1 6 TO2 4 JO2 5 ZOI 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 t1INNER JOIN (SELECT ID,MIN(Count) AS MinCount FROM Table GROUP BY ID) t2ON t2.ID=t1.IDAND t2.MinCount=t1.Count[/code]
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-11-05 : 03:03:11
or if sql 2005
SELECT ID,Count,CentreFROM(SELECT ROW_NUMBER() OVER (PARTITION BY ID ORDER BY Count) AS Seq,*FROM Table)tWHERE t.Seq=1