I have a problem that I’m not sure how to overcome and would really appreciate some direction.
Example data
Device Project status
a111 101 Ready
a222 102 Finished
a333 103 Ready
a444 104 Ready
a555 105 Ready
a111 106 Started
a111 107 Ready
a555 108 Started
I’m looking for a way to count the number of devices at ‘Ready’ status. However, when it comes to ‘Ready’ I only want to count it once AND don’t count it if that device has a status of anything other than ‘Ready’ in another project
Logic If ready in one or multiple projects = count once If ready in one but has a different status in any other project = do not count
Correct result should show only 2 as 'Ready'; 'a333' and 'a444'.
SELECT
'Ready' AS Header
, status
, count(distinct device)
FROM my_table
WHERE
project BETWEEN'101' AND '110'
GROUP BY status