Hi,
I am trying to merge below two queries in a single query such that
company_id,company_name,noOfOpenTickets,noOf PendingTickets
Need suggestions??
No Of open Tickets:
select c.company_id, (select company_name from company where id=company_id) as companyName,count(s.complaint_id) as noOfOpenTickets from complaint3 c ,complaint3_status s where s.id =(select max(d.id) from complaint3_status d where d.complaint_id =c.id and d.status_type in (1,3,4)) and s.status_value=0 and s.complaint_id =c.id and c.created_at >=20131001 AND c.created_at <=20131031 group by c.company_id
No of Pending Tickets:
select c.company_id, (select company_name from company where id=company_id) as companyName,count(s.complaint_id) as noOfPendingTickets from complaint3 c ,complaint3_status s where s.id =(select max(d.id) from complaint3_status d where d.complaint_id =c.id and d.status_type in (1,3,4)) and s.status_value=1 and s.complaint_id =c.id and c.created_at >=20131001 AND c.created_at <=20131031 group by c.company_id