grouping values in group by clause

You can calculate the period/quarter using (month+2)/3:

select year, (month+2) / 3 as quarter, sum(value)
from @tbl
group by year, (month+2) / 3
order by 1,2

See fiddle

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top