-- Output will be same but if the new 'state' gets added or removed from the database then we don't have to enter it manually. This query -- will take care of it and that's why this is Dyanmic.
Transact-SQL reference for PIVOT and UNPIVOT relational operators. Use these operators on SELECT statements to change a table-valued expression into another table.