SQL Server Management Studio – Using Row_Number, Partition, and filtering on Row_number

Let’s say you want to retrieve only the first row of each question type from the question type table. The 3rd SQL statement will give you your results, but let’s explain each of 3 SQL statements.

select RowNumber, question_type 
 from
   

SQL Server Management Studio – Retrieve one child row regardless of number of grand children from another child table with or without filtering

Let’s say you want to report on each child row, but you only want to see one row based on a grand child row with filtering on the grand child row. The following SQL will not work, but instead gets …

SQL Server Management Studio – Retrieve one parent row regardless of number of children when filtering on children

Let’s say you want to report on each parent row, but must join a child row to do filtering on the child row, but you only want to return one row per parent. The following SQL will not work, but …