我有一个这样的查询:
select to_date(to_char(registime, 'YYYY-MM'),'YYYY-MM') as dt,count(id) as total_call
from all_info
where alarm_id is null
group by dt
order by dt
结果是这样的:
dt total_call
2011-03-01 45
2011-04-01 61
2011-05-01 62
2011-06-01 41
2011-07-01 48
2011-08-01 42
2011-09-01 28
2011-10-01 39
我想要下面演示中的结果,表格形式:
2011-03-01 2011-04-01 2011-05-01 2011-06-01 ..........
45 61 62 41
我想使用crosstab,但它似乎不起作用?