全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1141 0
2016-08-18
哈哈,如题~题目如下:
The table WORK.PILOTS contains the following data:
Id   Name Jobcode Salary
001 Albert   PT1 50000
002 Brenda PT1 70000
003 Carl      PT1 60000
004 Donna  PT2 80000
005 Edward PT2 90000
006 Flora     PT3 100000

The data set was summarized to include average salary based on jobcode:
Jobcode Salary Avg
PT1 50000 60000
PT1 70000 60000
PT1 60000 60000
PT2 80000 85000
PT2 90000 85000
PT3 100000 100000

Which SQL statement could NOT generate this result?

A. select Jobcode, Salary, avg(Salary) label='Avg'
    from WORK.PILOTS
    group by Jobcode
    order by Id;

B. select Jobcode, Salary,
    (select avg(Salary)
     from WORK.PILOTS as P1
     where P1.Jobcode=P2.Jobcode) as Avg
    from WORK.PILOTS as P2
    order by Id;

C. select Jobcode, Salary,
    (select avg(Salary)
     from WORK.PILOTS
     group by Jobcode) as Avg
    from WORK.PILOTS
    order by Id;

D. select Jobcode, Salary, Avg
    from WORK.PILOTS,
    (select Jobcode as Jc, avg(Salary) as Avg
     from WORK.PILOTS
     group by 1)
    where Jobcode=Jc
    order by Id;

麻烦大家解释一下B C D选项~
谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群