SQL经典面试题及答案(6)

2021-04-05 03:33

SQL经典面试题及答案

部门dep 一月份二月份三月份

--------------------------------------

01 10 null null

02 10 8 null

03 null 5 8

04 null null 9

------------------------------------------

1)

select a.部门名称dname,b.业绩yj as '一月份',c.业绩yj as '二月份',d.业绩yj as '三月份'

from table1 a,table2 b,table2 c,table2 d

where a.部门dep = b.部门dep and b.月份mon = '一月份' and a.部门dep = c.部门dep and c.月份mon = '二月份' and

a.部门dep = d.部门dep and d.月份mon = '三月份' and

2)

select a.dep,

sum(case when b.mon=1 then b.yj else 0 end) as '一月份', sum(case when b.mon=2 then b.yj else 0 end) as '二月份', sum(case when b.mon=3 then b.yj else 0 end) as '三月份', sum(case when b.mon=4 then b.yj else 0 end) as '四月份', sum(case when b.mon=5 then b.yj else 0 end) as '五月份', sum(case when b.mon=6 then b.yj else 0 end) as '六月份', sum(case when b.mon=7 then b.yj else 0 end) as '七月份', sum(case when b.mon=8 then b.yj else 0 end) as '八月份', sum(case when b.mon=9 then b.yj else 0 end) as '九月份', sum(case when b.mon=10 then b.yj else 0 end) as '十月份',


SQL经典面试题及答案(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:高一地理教案 2.6气候的形成和变化

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: