All rows in a table have a type
field which is either 0 or 1.
I need to count rows with 0 and with 1 in one query. So that result should look something like:
type0 | type1
------+------
1234 | 4211
How can this be implemented?
select type, count(type) from tbl_table group by type;
Lessee...
SELECT
SUM(CASE type WHEN 0 THEN 1 ELSE 0 END) AS type0,
SUM(CASE type WHEN 1 THEN 1 ELSE 0 END) AS type1
FROM
tableX;
This has not been tested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With