Mysql Merge 2 queries -
i trying merge below queries in single row such results come in same row. company_id common in both queries. need suggestion ???
1st query:
select c.id company_id, avg(datediff(cdr.created_at,cd.send_to_brand_date)) avg_time_taken_for_first_comment complaint3 c3, complaint3_details cd, complaint3_diary cdr, company c c3.id=cd.complaint_id , cd.send_to_brand=1 , c.id=c3.company_id , cdr.complaint_id=c3.id , cdr.id in( select min(id) complaint3_diary complaint_id=c3.id , user_id in( select id user3 user_type=2)) , c.id=351 , c3.created_at>='2014-01-01' , c3.created_at<='2014-01-30' , cdr.created_at>='2014-01-01' , cdr.created_at<='2014-01-30'
2nd query:
select c.id company_id, avg(datediff(cs.created_at,cd.send_to_brand_date)) avg_time_closure complaint3 c3, complaint3_status cs, complaint3_details cd, company c c3.id=cs.complaint_id , c3.id=cd.complaint_id , c.id=c3.company_id , cs.complaint_id=c3.id , cd.send_to_brand=1 , cs.id in( select max(id) complaint3_status complaint_id=c3.id , status_type in(2) ) , cs.status_value=2 , c.id=272 , cs.created_at>='2014-01-01' , cs.created_at<='2014-01-30'
select * (<1st query>) q1 join (<2nd query>) q2 on q1.company_id = q2.company_id
Comments
Post a Comment