Suppose there is such a query that displays the number of rows for each filter:

SELECT (`delivery`), COUNT(*) FROM prod_data WHERE `delivery` = 'Евросоюз Cream' OR `delivery` = 'Cream BetaPost' GROUP BY `delivery` 

Question: How can I calculate the sum of the number of rows in the above sample?

  • @Legionary why such meaningless editing? cruim - and for some reason you are also accepting it - Alexey Shimansky
  • @ Alexey Shimansky edit was made almost simultaneously with you, at the time of clicking "edit" there were no changes made. After clicking "Save Changes" - the message was reflected with your editing. But mine has already been sent. My corrections were not only "count" but also code formatting (relative to the initial version). Your edit at that time was not reflected. - Legionary
  • @Legionary approx. Found out. - Alexey Shimansky

3 answers 3

You can count the number without grouping, in fact, you get the same amount:

 SELECT COUNT(*) FROM prod_data WHERE `delivery` = 'Евросоюз Cream' OR `delivery` = 'Cream BetaPost' 
     SELECT SUM(x) FROM (( SELECT COUNT(*) as x FROM prod_data WHERE `delivery` = 'Евросоюз Cream' OR `delivery` = 'Cream BetaPost' GROUP BY `delivery` ) as prom) 
       SELECT (`delivery`), COUNT(*) FROM prod_data WHERE `delivery` IN ( 'Евросоюз Cream', 'Cream BetaPost' ) GROUP BY `delivery` WITH ROLLUP