How to retrieve the top N rows for each group

--Solution for SQL Server 2000 and later  
  
SELECT ProductID,  
       CategoryID,  
       UnitPrice  
FROM   @Products p1  
WHERE  ProductID IN (SELECT TOP 3 ProductID  
                     FROM   @Products p2  
                     WHERE  p1.CategoryID = p2.CategoryID  
                     ORDER  BY UnitPrice DESCORDER BY CategoryIDUnitPrice DESC
source : http://gallery.technet.microsoft.com/scriptcenter/How-to-retrieve-the-top-N-248cdc67

Yorumlar

Bu blogdaki popüler yayınlar

c# E-fatura görüntüleme aracı

Kablo Modem Netmaster CBW-700V VPN Ayarları

Sql mükerrer kayıtları silmek