![How to Get Top N Records Per Group? - Ranking Function - Interview Question of the Week #156 - SQL Authority with Pinal Dave How to Get Top N Records Per Group? - Ranking Function - Interview Question of the Week #156 - SQL Authority with Pinal Dave](https://blog.sqlauthority.com/i/d/top2records1.png)
How to Get Top N Records Per Group? - Ranking Function - Interview Question of the Week #156 - SQL Authority with Pinal Dave
![SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - SQL Authority with Pinal Dave SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - SQL Authority with Pinal Dave](https://blog.sqlauthority.com/i/b/unionall.gif)
SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - SQL Authority with Pinal Dave
![SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - SQL Authority with Pinal Dave SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - SQL Authority with Pinal Dave](https://blog.sqlauthority.com/wp-content/uploads/2008/03/unionall1.gif)
SQL SERVER - How to Retrieve TOP and BOTTOM Rows Together using T-SQL - SQL Authority with Pinal Dave
![How to add subtotal row after the bottom row using a grouping set in SQL Server 2014 - Stack Overflow How to add subtotal row after the bottom row using a grouping set in SQL Server 2014 - Stack Overflow](https://i.stack.imgur.com/9q6MA.png)