首页 > 试题广场 >

假设销售团队拥有一张账目表account,表中每行记录记录着

[单选题]
假设销售团队拥有一张账目表account,表中每行记录记录着销售员2016年到2018年每个月的销售额,如果销售员当月没有销售额,则不录入到表中,目前管理员想查看下2018年每个月都有销售额的销售人员的总销售额,
那么sql语句是:
create table `account`(
    `id` int(11) not null auto_increment,
    `year` int(11) not null comment '年份',
    `name` char(30) not null comment '销售员',
    `month` int(11) not null comment '月份',
    `sales` int(11) not null comment '销售额',
    primary key(`id`)
)engine = innodb;

  • select name, sum(sales) from account where month = 12 and year = 2018 group by name having count(sales)=12 order by name asc
  • select name, sum(sales) from account where month = 12 group by name having year=2018 order by name asc
  • select name, sum(sales) from account where year = 2018 group by name having count(sales)=12 order by name asc
  • select name, sum(sales) from account group by name having year=2018 and count(sales)=12 order by name asc

这道题你会答吗?花几分钟告诉大家答案吧!