Oracle
 sql >> Database >  >> RDS >> Oracle

Pivot in Oracle 11g

Eri vicino:

select age, nvl(male, 0) male, nvl(female, 0) female
from    
(
  select age,  gender,  sum(hours) as hours
  from table1
  group by age, gender
)
pivot
(
  sum(hours) for gender in ('Male' as male, 'Female' as female)
);