Hi, I need to generate the report daily with date wise, I have written it with a case statement, How to avoid case statement to minimize the query because I need to add complete dates of a month. Please help me to write it in dynamic way.
SELECT City,
Sum(case when CONVERT(VARCHAR(10),Date,126)='2018-11-05' THEN SaleAmount else 0 end) as '2018-11-05',
Sum(case when CONVERT(VARCHAR(10),Date,126)='2018-11-04' THEN SaleAmount else 0 end) as '2018-11-04',
Sum(case when CONVERT(VARCHAR(10),Date,126)='2018-11-03' THEN SaleAmount else 0 end) as '2018-11-03'
FROM Survey group by City