pivot table in sql server

Source: www.infocaptor.com