I have one query result as:
Wname NewCases
Mon 2
Tues 1
Sat 3
Second query result as:
Wname FollowUp
Tues 3
Wed 4
Friday 2
I need to write mysql query to get result as:
Wname NewCases FollowUp
Mon 2 0
Tues 1 3
Wed 0 4
Fri 0 2
Sat 3 0
my 1st query:
Select substring(dayname(Dated),1,3) as wname,
count(RegId) as NewCases
from patienttable
where Patient_Type='New'
and week(Dated)=week(now())
group by dayname(Dated)
order by Dated
2nd query:
Select substring(dayname(Dated),1,3) as wname,
count(RegId) as FollowUp
from patienttable
where Patient_Type='FollowUp'
and week(Dated)=week(now())
group by dayname(Dated)
order by Dated
There is no need to join the queries.
You can do it in one query with conditional aggregation: