counting null data in MySQL -


Assuming I have a table with data:

  name status Bob Single Bob Single Jane Empty Tina got married to the blank Shine  

I want the status "single or data blank" to mean single. So if the data can be read as a single blank script and can be trusted together. So I can show results like this:

  Single Married 3 1  

I have tried with this and it does not work: / P>

  SELECT SUM (IF (condition = 'single', 1,0)) AS Single, SAM (if (condition = 'married', 1,0)) Married AS   

Use:

  SELECT SUM (case when x. Status = 'single' OR x position is zero then 1 ELSE 0 END), as a single (Same (case when x.status = 'married' then 1 ELSE 0 END) from marriage (select t.name, T .status FROM YOUR_TABLE t) x  

Comments