steven0814
5207 号测试 成员, 2022-01-14 11:02:26 加入
2.0k
个人主页浏览
7h37m
在线时长
  • 经典 SQL 数据库笔试题及答案整理!

    2022-01-14 11:26

    第3大道题的第2小题答案:

    原答案

    select DATE_FORMAT(a.crttime,'%m-%d-%Y') ,username,count(*) from testCase a,User b where a.crtUser = b.UserId group by DATE_FORMAT(a.crttime,'%m-%d-%Y'),b.username, having status = '成功',执行该SQL语句会报错

    正确答案应该为:

    select DATE_FORMAT(a.crttime,'%Y-%m-%d'),username,count(distinct(a.caseName)) from testcase a,user b
    where a.crtUser = b.UserId and status ='成功' group by DATE_FORMAT(a.crttime,'%Y-%m-%d'),b.username ;