I have the following statetment:
Select a.Data AS Data_A,b.Data AS Data_B,
(Select Round(Sum(C.Value)) From Values c
Where
(Year(c.TimeStamp) = x) and
(Month(c.TimeStamp) = y)
) AS MonthYear
From Table1 a Left Join Table2 b on (a.ID = b.ID)
Ist there any way to add a column to the select clause based on my desired range of date? (where Year(c.TimeStamp) < 2019 and Month(c.TimeStamp) <= 12)
Example1 - i want to see the data for 1 month:
Select a.Data AS Data_A,b.Data AS Data_B,
(Select Round(Sum(C.Value)) From Values c
Where
(Year(c.TimeStamp) = 2018) and
(Month(c.TimeStamp) = 1)
) AS Jan2018
From Table1 a Left Join Table2 b on (a.ID = b.ID)
Example2: i want to see the data for 3 months
Select a.Data AS Data_A,b.Data AS Data_B,
(Select Round(Sum(C.Value)) From Values c
Where
(Year(c.TimeStamp) = 2018) and
(Month(c.TimeStamp) = 1)
) AS Jan2018,
(Select Round(Sum(C.Value)) From Values c
Where
(Year(c.TimeStamp) = 2018) and
(Month(c.TimeStamp) = 2)
) AS Feb2018,
(Select Round(Sum(C.Value)) From Values c
Where
(Year(c.TimeStamp) = 2018) and
(Month(c.TimeStamp) = 3)
) AS Mar2018
From Table1 a Left Join Table2 b on (a.ID = b.ID)
I hope my question is understandable. :)
Thank you for reading.
2018is not a validMonth()