A
A
Artem2017-08-17 15:16:23
SQL
Artem, 2017-08-17 15:16:23

How to combine 2 queries with different where?

There are 2 requests:

SELECT COUNT(schedule.id) AS Total, doctor_id, doctor.last_name  FROM `schedule` 
INNER JOIN doctor ON `schedule`.doctor_id = doctor.id
WHERE `date` BETWEEN '2017-06-06' AND '2017-08-06' 
GROUP BY doctor_id

SELECT COUNT(schedule.id) AS Worked, doctor_id, doctor.last_name  FROM `schedule` 
INNER JOIN doctor ON `schedule`.doctor_id = doctor.id
WHERE `date` BETWEEN '2017-06-06' AND '2017-08-06'  AND schedule.appointment_cnt > 0
GROUP BY doctor_id

How to combine them in such a way that at the output we get a table like Total, Worked, doctor.last_name

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question