select ExDate, SUM(case when Dept='A' then expense else 0 end)[Store A Expense],
SUM(case when Dept='B' then expense else 0 end)[Store B Expense],
SUM(case when Dept='C' then expense else 0 end)[Store C Expense]
from expenseTable where Dept in ('A','B','C') group by ExDate
Kannan KR, Team Lead working in a Mobile Application Development Company in Noida, India. Having 8+ years of experience in Web, Mobile and Application Development. Focused on .Net, Java, VB, SQL Server and related technologies as both a career and a personal passion