I need to break date span into quarter of the year. I'm using the below query in main query but as the maximum value reached in the cross apply statement I'm not getting the latest quarter's from the select statement. How to increase the number dynamically in the Values of the select statement. I suppose to get 2022Q2, 2022Q3 and currently its 2022Q4 but the query stopped at 2022Q1 because the Values in the select statement is 12 maximum.

```sql
Select CAST(YEAR(DATEADD(QQ,n,'2019-01-01')) AS VARCHAR(4)) + 'Q' + DATENAME(qq,DATEADD(QQ,n,'3000-12-31')) as Year_Quarter
from(
SELECT TOP(1+DATEDIFF(QQ,'2019-01-01','2999-12-31')) n
FROM (VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12)) rc(n)) as x
order by 1

```

```none
2019Q1
2019Q2
2019Q3
2019Q4
2020Q1
2020Q2
2020Q3
2020Q4
2021Q1
2021Q2
2021Q3
2021Q4
2022Q1

```

I tried adding the numbers to the Values then getting

```sql
Select CAST(YEAR(DATEADD(QQ,n,'2019-01-01')) AS VARCHAR(4)) + 'Q' + DATENAME(qq,DATEADD(QQ,n,'3000-12-31')) as Year_Quarter
from(
SELECT TOP(1+DATEDIFF(QQ,'2019-01-01','2999-12-31')) n
FROM (VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15)) rc(n)) as x
order by 1

```

I want the Values in the inner select to add dynamically to get the current quarter.

```none
2019Q1
2019Q2
2019Q3
2019Q4
2020Q1
2020Q2
2020Q3
2020Q4
2021Q1
2021Q2
2021Q3
2021Q4
2022Q1
2022Q2
2022Q3
2022Q4

```