WITH tmp AS
(select '张一' as names, '2014年1月' as dates, '90' as sorcs from dual union
select '张四' as names, '2014年1月' as dates, '66' as sorcs from dual union
select '张一' as names, '2014年2月' as dates, '84' as sorcs from dual union
select '张二' as names, '2014年2月' as dates, '75' as sorcs from dual union
select '张四' as names, '2014年2月' as dates, '48' as sorcs from dual union
select '张三' as names, '2014年3月' as dates, '75' as sorcs from dual union
select '张四' as names, '2014年3月' as dates, '96' as sorcs from dual union
select '张一' as names, '2014年4月' as dates, '94' as sorcs from dual union
select '张四' as names, '2014年4月' as dates, '75' as sorcs from dual union
select '张三' as names, '2014年5月' as dates, '84' as sorcs from dual union
select '张四' as names, '2014年6月' as dates, '75' as sorcs from dual union
select '张二' as names, '2014年7月' as dates, '64' as sorcs from dual union
select '张一' as names, '2014年8月' as dates, '77' as sorcs from dual )
SELECT names,
SUM(CASE WHEN dates ='2014年1月' THEN sorcs END ) AS "2014年1月" ,
SUM(CASE WHEN dates ='2014年2月' THEN sorcs END ) AS "2014年2月",
SUM(CASE WHEN dates ='2014年3月' THEN sorcs END ) AS "2014年3月"
FROM tmp
GROUP BY names
你这个是要行列互换吧?
这个不是分组查询,你这个要做的事列转行