如何在这种情况下使用子查询

时间:2019-11-12 06:57:17

标签: subquery

获取子查询返回的行数超过1,但我想按多个日期获取访问次数

SELECT COUNT('visit') as total_visit1,employee_id, 
    (SELECT COUNT('visit') as total_visit2 from employee_meeting
        WHERE visit_date between '2018-07-29' and '2018-09-29 23:59:59.999' and employee_id='123') as total_new FROM employee_meeting WHERE visit_date between '2018-07-29' and '2018-09-29 23:59:59.999' and employee_id='123'

1 个答案:

答案 0 :(得分:0)

尝试一下

SELECT `employee_id`,date_format(`visit_date`,'%d-%M-%Y') dt,count(*) FROM `employee_meeting` group by `employee_id`,date_format(`visit_date`,'%d-%M-%Y')