I am trying to write an SQL Function to count attendance at a specific set of events. I cannot seem to get the code correct to do a count. Everyone seems to get all of the points or none of the points.
SELECT CASE WHENCOUNT(RecordsID)>3 THEN 4 WHENCOUNT(RecordsID)>0 THENCOUNT(RecordsID) ELSE 0 END FROM participants PR INNERJOIN special_event EV ON PR.EVENTID=EV.ID WHERE EV.EVENTID IN('2018-09-15-Arden Hills','2019-04-06-Bloomington','2019-04-04-19','2019-03-21-Duluth','2019-01-26--Duluth','2018-10-13-Duluth','2019-06-29 Duluth','2019-03-09-Diuluth','2018-11-09-Duluth','2018-12-04HolidayDinner','2018-11-02-Duluth','2018-10-12-Duluth','2019-05-02-duluth','2018-11-15 Duluth','2018-09-06-Duluth 00','2019-02-07 Duluth','2019-02-01 Fort Meyers','2018-08-09 Green Bay','2018-Oct Duluth-00','2018-10-03 St Paul','2018-11-10-Blloomington','2018-05-03-Duluth','2018-09-24-Miami','2019-04-13-Minneapolis','2019-06-21 to 06-23','2019-03-26-Phoenix','2019-06-27-PresDinner','2019-06-28-Duluth 00','2018-09-16-Duluth-01','2019-03-23 San Diego','2019-06-29-SASS','2019-04-06-Seattle','2019-03-02 St. Paul','2019-04-25-St Paul','2019-02-08 St, Paul','2018-08-23-9-3 St. Paul','2018-11-14-Duluth','2018-05-31-Twin Cities','2018-12-8-18','2019-02-02-DC') AND PR.ATTENDED = 1
Any guidance would be appreciated as this concept is central to how we move forward.
Joel Clasemann
I am trying to write an SQL Function to count attendance at a specific set of events. I cannot seem to get the code correct to do a count. Everyone seems to get all of the points or none of the points.
SELECT
CASE
WHEN COUNT(RecordsID) >3 THEN 4
WHEN COUNT(RecordsID) >0 THEN COUNT(RecordsID)
ELSE 0
END
FROM participants PR INNER JOIN special_event EV ON PR.EVENTID=EV.ID
WHERE EV.EVENTID IN ('2018-09-15-Arden Hills', '2019-04-06-Bloomington', '2019-04-04-19', '2019-03-21-Duluth', '2019-01-26--Duluth', '2018-10-13-Duluth', '2019-06-29 Duluth', '2019-03-09-Diuluth', '2018-11-09-Duluth', '2018-12-04HolidayDinner', '2018-11-02-Duluth', '2018-10-12-Duluth', '2019-05-02-duluth', '2018-11-15 Duluth', '2018-09-06-Duluth 00', '2019-02-07 Duluth', '2019-02-01 Fort Meyers', '2018-08-09 Green Bay', '2018-Oct Duluth-00', '2018-10-03 St Paul', '2018-11-10-Blloomington', '2018-05-03-Duluth', '2018-09-24-Miami', '2019-04-13-Minneapolis', '2019-06-21 to 06-23', '2019-03-26-Phoenix', '2019-06-27-PresDinner', '2019-06-28-Duluth 00', '2018-09-16-Duluth-01', '2019-03-23 San Diego', '2019-06-29-SASS', '2019-04-06-Seattle', '2019-03-02 St. Paul', '2019-04-25-St Paul', '2019-02-08 St, Paul', '2018-08-23-9-3 St. Paul', '2018-11-14-Duluth', '2018-05-31-Twin Cities', '2018-12-8-18', '2019-02-02-DC')
AND PR.ATTENDED = 1
Any guidance would be appreciated as this concept is central to how we move forward.