I have two tables , Table #1 => tbl_notification_flow has the following information :
app_status
Booked
Notified
Missed
Defaulted
With the app_status being the column name and Table #2 => tbl_appointment has the following information :
id app_status
1 Booked
3 Missed
4 Missed
5 Missed
6 Missed
7 Booked
8 Booked
9 Booked
10 Booked
11 Booked
12 Booked
13 Booked
14 Booked
15 Booked
17 Booked
18 Booked
19 Booked
20 Defaulted
21 Notified
With id and app_status being the columns ,
I want to get a count of all the app_status based on the number of times they have appeared on Table #2 ,
I tried the following query :
SELECT COUNT(tbl_appointment.id)AS total_count, tbl_appointment.`app_status`
FROM tbl_appointment
WHERE (tbl_appointment.`app_status`) IN
(
SELECT tbl_notification_flow.`notification_type` AS app_status
FROM tbl_notification_flow
WHERE tbl_notification_flow.notification_type != 'Other'
)
It gets the following result :
total_count app_status
19 Booked
Please help with the best query to get the right results.
Best Answer
with result: