These all dates are of Monday of October i want it to do Dynamically. It would be better if can do the same for Mon, Tue , Wed only, and last column should be sum[As that is showing in excel sheet
select ClientName,JobName, JobTime, [2018-09-03], [2018-09-10], [2018-09-17], [2018-09-24] from (select ClientName,JobName, JobTime, convert(date,reporttime,101) as [ReportDate] from StaleFileReport where convert(varchar,ReportTime,102) in ('2018.09.03','2018.09.10','2018.09.17','2018.09.24') group by ClientName, JobName,JobTime, convert(date,reporttime,101))x PIVOT ( Count([ReportDate]) FOR [ReportDate] in ( [2018-09-03], [2018-09-10], [2018-09-17], [2018-09-24]) ) AS P
text
. - Larnu