By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Table 'fiddle.tab' doesn't exist
Records: 8 Duplicates: 0 Warnings: 0
@sql |
---|
SELECT company_name,SUM( `action` = 'EMAIL' ) AS EMAIL,SUM( `action` = 'PRINT' AND `pagecount` = 1 ) AS PRINTpage1,SUM( `action` = 'PRINT' AND `pagecount` = 2 ) AS PRINTpage2,SUM( `action` = 'PRINT' AND `pagecount` = 3 ) AS PRINTpage3 FROM `tab` GROUP BY company_name |
Statement prepared
company_name | PRINTpage1 | PRINTpage2 | PRINTpage3 | |
---|---|---|---|---|
Company A | 0 | 0 | 1 | 3 |
Company B | 1 | 1 | 2 | 0 |