I am stuck and need advice. This may be something simple, however, I am a beginner here and trying to learn as quickly as possible, so please bear with me. I have a table containing attendance data in "A" / "P" format. I am trying to show in a report how many people within a class have missed three or more times with a date range. For the most part I have the SQL statement doing all of the work with one exception. I can show a sum for how many times someone has missed, but I cannot figure out how to only show students with greater than 3 absences. I am entering the following in an expression on the column I want the data to return in:
=SUM(IIF(Fields!Attendance.Value ="A",1,NOTHING))
If I write the expression like this:
=SUM(IIF(Fields!Attendance.Value ="A",1,NOTHING))>=3
I get TRUE/FALSE returns. That would be ok if I could then figure out how to only shows the TRUE returns.
Any advice is appreciated!
My entire SQL statement - there are two other datasets that get called to pull data into this one.
SELECT smgp_group.group_id
, smgp_group.group_name
, core_v_person_basic.last_name + ', ' + core_v_person_basic.nick_name as Name
, core_v_person_basic.birth_date AS Birthdate
, '*' + CONVERT(varchar, core_v_person_basic.person_id) + '*' AS person_id
, core_v_person_basic.street_address_1
, core_v_person_basic.city + ',' + core_v_person_basic.state + ' ' + core_v_person_basic.postal_code AS Citystatezip
, core_v_person_basic.home_phone
, core_v_person_basic.email
, core_lookup.lookup_value AS [Group Role]
, CATD.occurrence_end_time
, CATD.Attendance as attendance
, MAX(CATD.DateLastAttended) AS Datelastattended
, CATD.occurrence_end_time AS [Start Date]
, CATD.occurrence_end_time AS [End Date]
, '*$' + CONVERT(varchar, CATD.occurrence_id) + '*' AS 'occurrence_id'
, core_v_person_basic.cell_phone
FROM smgp_group
INNER JOIN cust_v_attendanceroll AS CATD
INNER JOIN core_lookup ON CATD.role_luid = core_lookup.lookup_id
INNER JOIN core_v_person_basic ON CATD.person_id = core_v_person_basic.person_id ON smgp_group.group_id = CATD.group_id
where CATD.occurrence_end_time between @startdate AND @enddate and smgp_group.group_id IN (@group)
GROUP BY smgp_group.group_id, smgp_group.group_name, core_v_person_basic.last_name,core_v_person_basic.nick_name, core_v_person_basic.birth_date, core_v_person_basic.street_address_1,
core_v_person_basic.city + ',' + core_v_person_basic.state + ' ' + core_v_person_basic.postal_code, core_v_person_basic.home_phone,
core_v_person_basic.email, core_lookup.lookup_value, CATD.occurrence_end_time, CATD.Attendance, CATD.occurrence_id, core_v_person_basic.person_id,
core_v_person_basic.cell_phone
HAVING attendance = 'A'
ORDER BY attendance