-
Notifications
You must be signed in to change notification settings - Fork 0
Queries to export data
Xavier Damman edited this page Mar 29, 2022
·
3 revisions
All users that are admin of at least one collective hosted by allforclimate (Host Id: 73495)
SELECT max(uc.slug) as profile, u.email, STRING_AGG(c.slug, ', ') as collectives
FROM "Members" m
LEFT JOIN "Collectives" uc ON uc.id = m."MemberCollectiveId"
LEFT JOIN "Collectives" c ON c.id = m."CollectiveId"
LEFT JOIN "Users" u ON u."CollectiveId" = m."MemberCollectiveId"
WHERE m.role='ADMIN'
AND m."CollectiveId" IN (SELECT "CollectiveId" FROM "Members" WHERE role = 'HOST' AND "MemberCollectiveId"='73495')
AND u.email IS NOT NULL
AND c."isActive" IS TRUE
AND c. "deletedAt" IS NULL
GROUP BY email