need a query to get the following two select with one connection to mysql -
i need count(calmness) table entity_epoch_data in mysql twice :
where column of calmness>0 , calmness<0
so connect database twice follow:
select count(calmness) omid.entity_epoch_data calmness<0; select count(calmness) omid.entity_epoch_data calmness>=0; i wondering if can combine these 2 query , result 1 table 1 connection?
i tried did not work:
select c1,c2 ( select count(calmness) c1 omid.entity_epoch_data calmness<0, select count(calmness) c2 omid.entity_epoch_data calmness>=0); can help?
this can done using sum() expression,when using sum() within expression evaluates true/false i.e 1/0 based on result of expression ,note using aggregate function without grouping them result in single row
select sum(calmness < 0) c1, sum(calmness >= 0) c2 omid.entity_epoch_data ;
Comments
Post a Comment