@@ -165,17 +165,14 @@ AND NOT EXISTS (SELECT * FROM GroupCustomisations AS GCInner
165165 GroupID,
166166 GroupLabel,
167167 GroupDescription,
168- (SELECT COUNT(*) FROM ( SELECT
169- da.CentreID,
170- COALESCE(ucd.Email, u.PrimaryEmail) AS EmailAddress,
171- u.JobGroupId
172- FROM DelegateAccounts AS da WITH (NOLOCK)
173- INNER JOIN Centres AS c WITH (NOLOCK) ON c.CentreID = da.CentreID
174- INNER JOIN Users AS u WITH (NOLOCK) ON u.ID = da.UserID
175- LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = da.UserID AND ucd.CentreID = da.CentreID
176- INNER JOIN JobGroups AS jg WITH (NOLOCK) ON jg.JobGroupID = u.JobGroupID where c.CentreID = @centreId
177- AND u.JobGroupID = (select JobGroupID from JobGroups where JobGroupName = GroupLabel)) D Where
178- EmailAddress LIKE '%_@_%.__%') AS DelegateCount,
168+ (SELECT COUNT(*)
169+ FROM GroupDelegates AS gd WITH (NOLOCK)
170+ JOIN DelegateAccounts AS da WITH (NOLOCK) ON da.ID = gd.DelegateID
171+ JOIN Users AS u WITH (NOLOCK) ON u.ID = da.UserID
172+ LEFT JOIN UserCentreDetails AS ucd WITH (NOLOCK) ON ucd.UserID = u.ID AND ucd.CentreID = da.CentreID
173+ WHERE gd.GroupID = g.GroupID
174+ AND (u.PrimaryEmail like '%_@_%.__%' OR ucd.Email is NOT NULL)
175+ AND da.Approved = 1 AND da.Active = 1) AS DelegateCount,
179176 ({ CourseCountSql } ) AS CoursesCount,
180177 g.CreatedByAdminUserID AS AddedByAdminId,
181178 au.Forename AS AddedByFirstName,
@@ -320,7 +317,9 @@ FROM GroupDelegates AS gd
320317 JOIN DelegateAccounts AS da ON da.ID = gd.DelegateID
321318 JOIN Users AS u ON u.ID = da.UserID
322319 LEFT JOIN UserCentreDetails AS ucd ON ucd.UserID = u.ID AND ucd.CentreID = da.CentreID
323- WHERE gd.GroupID = @groupId" ,
320+ WHERE gd.GroupID = @groupId
321+ AND (u.PrimaryEmail like '%_@_%.__%' OR ucd.Email is NOT NULL)
322+ AND da.Approved = 1 AND da.Active = 1" ,
324323 new { groupId }
325324 ) ;
326325 }
0 commit comments