Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Raggruppamento SQL:mostra solo 5 commenti per post

select
   *
FROM
   tblPost P
   OUTER APPLY
   (SELECT TOP 5 * FROM tblComment C  
      WHERE P.id = C.postid
      ORDER BY something) inline