Hi,
How to find out the fiscal quarter of the day based on the start_date suppose in my example After writing this query my resultset will be like below
SELECT
MIN(START_DATE) AS start_date, MONTH(MIN(start_date)) AS p FROM xyz GROUP BY YEAR(START_DATE)
For each year the minimum value of date and month is shown like above. From this result I should calculate the quarternumber of year i.e whichever the minimum start_date as displayed it has to become as quarter1.Suppose my minimum date for year 2013 is '2013-04-01' then Quarter has to show it as 1 (4,5,6-Q1,7,8,9-Q2,10-11-12-Q3,1,2,3-Q4) and if my minimum start date for the year 2018 is '2018-02-01' then the quarter has to show it like this(2,3,4-Q1,5,6,7-Q2,8,9,10-Q3,11,12,1-Q4)
Based on this above date now my sample output look like which is attached in below sheet
How to do in this query .. help me to resolve this issue. I am not able to get any logic how to design the query based on the above scenario...
My sample input and output file which is in database it is attached below.
How to find out the fiscal quarter of the day based on the start_date suppose in my example After writing this query my resultset will be like below
SELECT
MIN(START_DATE) AS start_date, MONTH(MIN(start_date)) AS p FROM xyz GROUP BY YEAR(START_DATE)
Code:
start_date p
2001-01-01 1
2002-01-01 1
2003-01-01 1
2004-01-01 1
2005-01-01 1
2006-01-01 1
2007-01-01 1
2013-04-01 4
2018-02-01 2
2019-01-01 1
For each year the minimum value of date and month is shown like above. From this result I should calculate the quarternumber of year i.e whichever the minimum start_date as displayed it has to become as quarter1.Suppose my minimum date for year 2013 is '2013-04-01' then Quarter has to show it as 1 (4,5,6-Q1,7,8,9-Q2,10-11-12-Q3,1,2,3-Q4) and if my minimum start date for the year 2018 is '2018-02-01' then the quarter has to show it like this(2,3,4-Q1,5,6,7-Q2,8,9,10-Q3,11,12,1-Q4)
Based on this above date now my sample output look like which is attached in below sheet
How to do in this query .. help me to resolve this issue. I am not able to get any logic how to design the query based on the above scenario...
My sample input and output file which is in database it is attached below.