How to group by specific range for every distinct years(by default years are distinct)?
Input:
my_table:
year count
1961 2
1963 6
1969 3
1975 5
1976 9
1978 5
1983 3
1984 1
1985 3
1986 5
1987 6
1989 13
.
.
.
I have tried,
select sum(count) as total_count,
(year || '-' || year+9) as year_range
from my_table
group by year
But, the code is not giving correct results.
Expected output:
total_count year_range
11 1961-1970
9 1963-1972
22 1969-1978
23 1975-1984
23 1978-1987
.
.
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…