fbpx

23. Using Unpivot

This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
 

Given a table that displays the office maintenance costs of a certain company. The table specifies the city where the office is located, the monthly billing date, and the various costs (cleaning, equipment, and electricity).

 CREATE TABLE OfficeCosts    
  (    
     OfficeCity     VARCHAR(100)    
    ,BillDate       DATETIME    
    ,Cleaning       DECIMAL(8,3)    
    ,Equipment      DECIMAL(8,3)    
    ,Electricity    DECIMAL(8,3)    
  )    
  GO  

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…