Hi,
I need help in creating view based on below query
DEClare @CurrentQTR varchar(10),@CurrentMonth varchar(10) , @CurrentYear varchar(5)
SET @CurrentQTR = (select timeQuarter from CalendarTable where timeDate = CONVERT(Date, GetDate(), 101))
SET @CurrentMonth = (select timeMonth from CalendarTable where timeDate = CONVERT(Date, GetDate(), 101))
SET @CurrentYear = (select timeYear from CalendarTable where timeDate = CONVERT(Date, GetDate(), 101))
SELECT * FROM
(
select DISTINCT
LocationName ,
sum (CASE when Month = @CurrentMonth then TotalDeflation else 0 END) as MonthTotal,
sum (CASE when [Quarte]r = @currentQTR then TotalDeflation else 0 END) as QTRTotal,
sum (CASE when CurrentYear = @CurrentYear then TotalDeflation else 0 END) as YearTotal
FROM
Summarytable
group by locationName ) A
thanks