sql - How to Query Data for Certain Result -
okay here data set
event_id | workernumberid 3 | worker1 3 | worker2 3 | worker2 3 | worker3 5 | worker4 5 | worker5 3 | null 5 | null
i want query return below. though eventid 3 has 2 'worker2's still want count 1 non null item because same.
event_id | workernumberidcount (a count of not null items) 3 | 3 5 | 2
thoughts?
try this
select event_id,count(distinct workernumberid) workernumberidcount tablename workernumberid not null group event_id
Comments
Post a Comment