We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0d2507 commit d4cc31cCopy full SHA for d4cc31c
1 file changed
services/libs/data-access-layer/src/affiliations/index.ts
@@ -40,11 +40,13 @@ export async function findWorkExperiencesBulk(
40
AND "deletedAt" IS NULL
41
),
42
aggs AS (
43
- SELECT "organizationId", COUNT(DISTINCT "memberId") AS total_count
44
- FROM "memberOrganizations"
45
- WHERE "organizationId" IN (SELECT "organizationId" FROM relevant_orgs)
46
- AND "deletedAt" IS NULL
47
- GROUP BY "organizationId"
+ SELECT osa."organizationId", sum(osa."memberCount") AS total_count
+ FROM "organizationSegmentsAgg" osa
+ JOIN segments s ON s.id = osa."segmentId"
+ AND s."grandparentId" IS NOT NULL
+ AND s."parentId" IS NOT NULL
48
+ WHERE osa."organizationId" IN (SELECT "organizationId" FROM relevant_orgs)
49
+ GROUP BY osa."organizationId"
50
)
51
SELECT
52
mo.id,
0 commit comments