-
经典 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 ;