I need to sum up linear objects' length and to group them by intervals of several years. I have one table storing my objects like this :
- gid serial NOT NULL,
- year INTEGER,
- the_geom geometry(MULTILINESTRING) ;
I need a result like this :
period | length
----------------+-----------
2005 - 2014 | 18.6
1995 - 2004 | 16.1
1985 - 1994 | 7.6
1975 - 1984 | 19.0
1965 - 1974 | 28.2
1945 - 1964 | 10.2
before 1945 | 0.1
I can't find out on the Web how to perform this, except by producing each line with a different query and to use UNION ALL to merge them together, which is not so good.