mysql - Combining queries on the same table in to one query -
i trying statistics mysql table , keep single query. don't know how (or if possible). have these 2 queries:
select count(*) `accept` `status` `groupid` in (98779,98780) , `group` = 'order' , `status` = 'accept' and
select count(*) `price` `status` `groupid` in (98779, 98780) , `group` = 'quotation' , (`status` = 'final' or `status` = 'manualprice') my best suggestion combine them in single select this:
select (select count(*) `accept` `status` `groupid` in (98779, 98780) , `group` = 'order' , `status` = 'accept') accept, (select count(*) `price` `status` `groupid` in (98779, 98780) , `group` = 'quotation' , (`status` = 'final' or `status` = 'manualprice')) price is there better way?
select sum(if(`group` = 'order' , `status` = 'accept', 1,0)) `accept`, sum(if(`group` = 'quotation' , (`status` = 'final' or `status` = 'manualprice'), 1,0)) `price` `status` `groupid` in (98779,98780) , `group` in ('order', 'quotation') , `status` in ('accept', 'final', 'manualprice') edit same other answer 491243. have used additional if statement, seemingly is not needed.
Comments
Post a Comment