求一条比较艰难的SQL语句
[解决办法]
SELECT Province,city,brand,SUM(case when sale_month
='jan' then sale else 0) as jsn ,SUM(case when sale_month
='feb' then sale else 0) as feb
FROM TT GROUP BY Province,city,brand
动态用SP生成SQL语句
[解决办法]
select Province,city,brand,contact,
sum(case sale_month when 'Jan' then sale end) as Jan,
sum(case sale_month when 'Feb' then sale end) as Feb
from 数据如下
group by Province,city,brand,contact