读书人

求一条比较困难的SQL语句

发布时间: 2012-12-29 10:28:09 作者: rapoo

求一条比较艰难的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

读书人网 >IBM DB2

热点推荐