Hi
In below code i am getting error
SQL
UPDATE [SessionDeliveryParticipant]
SET Attendance = CASE
WHEN (
SELECT COUNT(*)
FROM [SessionDeliveryParticipant] AS sub
WHERE sub.SessionDeliveryCalendarID = SessionDeliveryCalendarID
AND sub.PresentInSession = 0
) = COUNT(*) THEN 1
ELSE 0
END;Thanks

Tuhin PaulRank #7 · 71.9K reputationPosted Jun 23, 2023, 1:25 PM EDT
UPDATE [SessionDeliveryParticipant] SET Attendance = CASE WHEN ( SELECT COUNT(*) FROM [SessionDeliveryParticipant] AS sub WHERE sub.SessionDeliveryCalendarID = [SessionDeliveryParticipant].SessionDeliveryCalendarID AND sub.PresentInSession = 0 ) = ( SELECT COUNT(*) FROM [SessionDeliveryParticipant] AS sub2 WHERE sub2.SessionDeliveryCalendarID = [SessionDeliveryParticipant].SessionDeliveryCalendarID ) THEN 1 ELSE 0 END;In this modified code, I added [SessionDeliveryParticipant]. as a prefix to the SessionDeliveryCalendarID column to clarify the table reference. Check that the column is referenced correctly in both the inner and outer queries. Please note that the code assumes you have a table named SessionDeliveryParticipant with columns named SessionDeliveryCalendarID, Attendance, and PresentInSession.
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 24, 2023, 12:20 AM EDT
Hi Tuhi
In Design mode where i can write this code in column. I want Attendance column should get automatically updated
UPDATE [SessionDeliveryParticipant] SET Attendance = CASE WHEN ( SELECT COUNT(*) FROM [SessionDeliveryParticipant] AS sub WHERE sub.SessionDeliveryCalendarID = [SessionDeliveryParticipant].SessionDeliveryCalendarID AND sub.PresentInSession = 0 ) = ( SELECT COUNT(*) FROM [SessionDeliveryParticipant] AS sub2 WHERE sub2.SessionDeliveryCalendarID = [SessionDeliveryParticipant].SessionDeliveryCalendarID ) THEN 1 ELSE 0 END;Thanks