До Oracle11 вы можете использовать этот стандартный трюк:
SQL> create table mytable (name,mydate,quantity)
2 as
3 select 'AAAAA', date '2008-12-10', 5 from dual union all
4 select 'AAAAA', date '2008-12-11', 2 from dual union all
5 select 'AAAAA', date '2008-12-12', 0 from dual union all
6 select 'AAAAA', date '2009-12-09', 3 from dual union all
7 select 'AAAAA', date '2009-12-10', 2 from dual union all
8 select 'AAAAA', date '2009-12-11', 3 from dual union all
9 select 'BBBBB', date '2008-12-10', 5 from dual union all
10 select 'BBBBB', date '2008-12-11', 2 from dual union all
11 select 'BBBBB', date '2008-12-12', 0 from dual union all
12 select 'BBBBB', date '2009-12-09', 3 from dual union all
13 select 'BBBBB', date '2009-12-10', 1 from dual union all
14 select 'BBBBB', date '2009-12-11', 0 from dual
15 /
Table created.
SQL> select name
2 , to_char(mydate,'dd-MON')
3 , sum(case extract(year from mydate) when 2008 then quantity end) quantity_2008
4 , sum(case extract(year from mydate) when 2009 then quantity end) quantity_2009
5 from mytable
6 group by name
7 , to_char(mydate,'dd-MON')
8 order by name
9 , to_char(mydate,'dd-MON')
10 /
NAME TO_CHA QUANTITY_2008 QUANTITY_2009
----- ------ ------------- -------------
AAAAA 09-DEC 3
AAAAA 10-DEC 5 2
AAAAA 11-DEC 2 3
AAAAA 12-DEC 0
BBBBB 09-DEC 3
BBBBB 10-DEC 5 1
BBBBB 11-DEC 2 0
BBBBB 12-DEC 0
8 rows selected.
С уважением,
Роб.