0

I have a progress column and an email date column. I'd like to have count 3 results as variables:

First: Progress = 0
Second: Progress = 1, EmailDate == 0000-00-00 00:00:00
Third: Progress = 1, EmailDate !== 0000-00-00 00:00:00

Currently I have the following:

SELECT Progress, COUNT(*) AS counter
FROM myTable
GROUP BY Progress

However, it isn't using the Email Date, when I try and use it, I get a zero value.

OptimusCrime
  • 14,662
  • 13
  • 58
  • 96
BN83
  • 902
  • 3
  • 9
  • 29

1 Answers1

1
SELECT
    SUM(IF(progress = 0,1,0)) AS Counter_1,
    SUM(IF(progress = 1 AND EmailDate = '0000-00-00 00:00:00',1,0)) AS Counter_2,
    SUM(IF(progress = 1 AND EmailDate != '0000-00-00 00:00:00',1,0)) AS Counter_3
FROM myTable
matks
  • 96
  • 7