Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

How to show Quarters Dynamically in SQL

$
0
0
Hi, At present am showing quarters from 2015-Q1 to Q4 , it should be like that, because report must show data for last 4 quarters only. Whenever i got data for "2016-Q1" then automatically report should change and display data for "2016-Q1" - "2015-Q4" - "2015-Q3" - "2015-Q2", it should be based on current quarter. same for upcoming quarters also. Is it possible?? again this is for reporting purpose only... there is 4 sets of query and using UNION and also in the logic its hard coded as: '2015 01' AS Qtr from Table WHERE (YYYYMM = 201503)UNION '2015 02' AS Qtr from Table WHERE (YYYYMM = 201506)UNION '2015 03' AS Qtr from Table WHERE (YYYYMM = 201509)UNION '2015 04' AS Qtr from Table WHERE (YYYYMM = 201512).please let me know if anyone need more details.

Viewing all articles
Browse latest Browse all 3145

Trending Articles