SQL “select where not in subquery” returns no results

Update: These articles in my blog describe the differences between the methods in more detail: NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL: SQL Server NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL: PostgreSQL NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL: Oracle NOT IN vs. NOT EXISTS vs. LEFT JOIN / IS NULL: MySQL There are three ways to do such a query: LEFT JOIN … Read more

TSQL PIVOT MULTIPLE COLUMNS

Since you want to pivot multiple columns of data, I would first suggest unpivoting the result, score and grade columns so you don’t have multiple columns but you will have multiple rows. Depending on your version of SQL Server you can use the UNPIVOT function or CROSS APPLY. The syntax to unpivot the data will be similar to: See SQL Fiddle … Read more