SELECT 年份,
SUM(case when 季度=1 then 销量 else 0 end) as 一季度,
SUM(case when 季度=2 then 销量 else 0 end) as 二季度,
SUM(case when 季度=3 then 销量 else 0 end) as 三季度,
SUM(case when 季度=4 then 销量 else 0 end) as 四季度
FROM Sales GROUP BY 年份;
SELECT 年份,
SUM(case when 季度=1 then 销量 else 0 end) as 一季度,
SUM(case when 季度=2 then 销量 else 0 end) as 二季度,
SUM(case when 季度=3 then 销量 else 0 end) as 三季度,
SUM(case when 季度=4 then 销量 else 0 end) as 四季度
FROM Sales GROUP BY 年份;