@stamhoofd/metabase 2.148.0 → 2.150.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -33
- package/dist/api.d.ts +28 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +27 -0
- package/dist/api.js.map +1 -1
- package/dist/report.d.ts +51 -4
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +75 -17
- package/dist/report.js.map +1 -1
- package/dist/sync-report.d.ts +54 -14
- package/dist/sync-report.d.ts.map +1 -1
- package/dist/sync-report.js +87 -15
- package/dist/sync-report.js.map +1 -1
- package/package.json +3 -3
- package/report/eenheden.sql +218 -173
- package/report/filters.sql +11 -41
- package/report/includes/all-non-platform-registrations-all-years.sql +58 -0
- package/report/includes/all-non-platform-registrations.sql +10 -0
- package/report/includes/all-registrations.sql +53 -0
- package/report/includes/child-leader-ratio.sql +4 -0
- package/report/includes/deduplicated-non-platform-registrations-all-years.sql +30 -0
- package/report/includes/deduplicated-non-platform-registrations.sql +30 -0
- package/report/includes/default-age-group-category.sql +2 -0
- package/report/includes/default-age-groups-with-category.sql +10 -0
- package/report/includes/filter-delivery-memberships.sql +2 -0
- package/report/includes/filter-has-delivery-membership.sql +11 -0
- package/report/includes/filter-registration-types.sql +2 -0
- package/report/includes/filter-statistics-memberships.sql +2 -0
- package/report/includes/gtp.sql +10 -48
- package/report/includes/keeo/{tak-categorie.sql → default-age-group-category.sql} +2 -15
- package/report/includes/keeo/filter-delivery-memberships.sql +5 -0
- package/report/includes/keeo/filter-statistics-memberships.sql +5 -0
- package/report/includes/members-per-year.sql +26 -0
- package/report/includes/membership-fee-type.sql +5 -0
- package/report/includes/participant-type.sql +2 -0
- package/report/includes/postal-code-coordinates.sql +2 -0
- package/report/includes/ravot/child-leader-ratio.sql +4 -0
- package/report/includes/ravot/default-age-group-category.sql +15 -0
- package/report/includes/ravot/filter-delivery-memberships.sql +4 -0
- package/report/includes/ravot/filter-statistics-memberships.sql +4 -0
- package/report/includes/ravot/gtp.sql +8 -29
- package/report/includes/ravot/participant-type.sql +7 -0
- package/report/includes/uldk.sql +16 -22
- package/report/includes/years-with-members.sql +11 -0
- package/report/jeugdbewegingen.sql +60 -167
- package/report/nationaal.sql +105 -81
- package/report/netwerk.sql +46 -34
- package/report/varia.sql +11 -9
- package/report/includes/aangesloten.sql +0 -23
- package/report/includes/aansluiting.sql +0 -26
- package/report/includes/facts-alle-jaren.sql +0 -53
- package/report/includes/facts.sql +0 -102
- package/report/includes/ingeschreven-voor.sql +0 -27
- package/report/includes/jaren.sql +0 -20
- package/report/includes/leden-per-jaar.sql +0 -29
- package/report/includes/leden.sql +0 -39
- package/report/includes/omkaderingscijfer.sql +0 -17
- package/report/includes/postcode-coordinaten.sql +0 -8
- package/report/includes/ravot/omkaderingscijfer.sql +0 -25
- package/report/includes/ravot/tak-categorie.sql +0 -28
- package/report/includes/ravot/type-deelnemers.sql +0 -22
- package/report/includes/tak-categorie.sql +0 -18
- package/report/includes/takken.sql +0 -20
- package/report/includes/tarief.sql +0 -14
- package/report/includes/type-deelnemers.sql +0 -14
package/report/netwerk.sql
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
-- @tab netwerk
|
|
2
2
|
-- title: Netwerk
|
|
3
|
-
-- description: Leden en eenheden per netwerk voor het gekozen
|
|
4
|
-
-- filters:
|
|
3
|
+
-- description: Leden en eenheden per netwerk voor het gekozen werkjaar.
|
|
4
|
+
-- filters: werkjaar, platformleden_opnemen
|
|
5
|
+
-- required: werkjaar
|
|
5
6
|
--
|
|
6
7
|
-- Het netwerk van een eenheid is een tag op de organisatie, bijgehouden per periode: een afgesloten
|
|
7
8
|
-- jaar houdt het netwerk waarmee het toen geregistreerd stond.
|
|
@@ -14,19 +15,23 @@
|
|
|
14
15
|
-- dimensions: Netwerk
|
|
15
16
|
-- metrics: Aantal kinderen, Aantal leiding, Aantal volwassenen
|
|
16
17
|
-- stacked: stacked
|
|
17
|
-
|
|
18
|
-
-- @include
|
|
18
|
+
WITH leden AS (
|
|
19
|
+
-- @include deduplicated-non-platform-registrations
|
|
20
|
+
)
|
|
19
21
|
SELECT
|
|
20
|
-
|
|
21
|
-
COUNT(DISTINCT CASE WHEN
|
|
22
|
-
COUNT(DISTINCT CASE WHEN
|
|
23
|
-
COUNT(DISTINCT CASE WHEN
|
|
24
|
-
FROM leden
|
|
25
|
-
JOIN _organizations_organization_tags
|
|
26
|
-
ON
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
organization_tags.name AS `Netwerk`,
|
|
23
|
+
COUNT(DISTINCT CASE WHEN leden.effective_category = 'child' THEN leden.member_id END) AS `Aantal kinderen`,
|
|
24
|
+
COUNT(DISTINCT CASE WHEN leden.effective_category = 'leader' THEN leden.member_id END) AS `Aantal leiding`,
|
|
25
|
+
COUNT(DISTINCT CASE WHEN leden.effective_category = 'adult' THEN leden.member_id END) AS `Aantal volwassenen`
|
|
26
|
+
FROM leden
|
|
27
|
+
JOIN _organizations_organization_tags
|
|
28
|
+
ON _organizations_organization_tags.organizationsId = leden.organization_id
|
|
29
|
+
AND _organizations_organization_tags.periodId = leden.period_id
|
|
30
|
+
JOIN organization_tags
|
|
31
|
+
ON organization_tags.id = _organizations_organization_tags.organizationTagsId
|
|
32
|
+
AND organization_tags.periodId = _organizations_organization_tags.periodId
|
|
33
|
+
GROUP BY organization_tags.name
|
|
34
|
+
ORDER BY organization_tags.name
|
|
30
35
|
|
|
31
36
|
-- @card locatie-eenheden
|
|
32
37
|
-- title: Locatie eenheden
|
|
@@ -38,17 +43,20 @@ ORDER BY t.name
|
|
|
38
43
|
-- dimensions: Postcode
|
|
39
44
|
-- metrics: Aantal eenheden
|
|
40
45
|
-- description: Een punt per postcode waar eenheden zitten. Het originele rapport zet een stip per eenheid; zonder coordinaat per eenheid is de postcode het dichtstbij.
|
|
41
|
-
|
|
42
|
-
-- @include
|
|
43
|
-
|
|
46
|
+
WITH leden AS (
|
|
47
|
+
-- @include deduplicated-non-platform-registrations
|
|
48
|
+
),
|
|
49
|
+
postcode_coordinaten AS (
|
|
50
|
+
-- @include postal-code-coordinates
|
|
51
|
+
)
|
|
44
52
|
SELECT
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
COUNT(DISTINCT
|
|
49
|
-
FROM leden
|
|
50
|
-
LEFT JOIN postcode_coordinaten
|
|
51
|
-
GROUP BY
|
|
53
|
+
leden.eenheid_postcode AS `Postcode`,
|
|
54
|
+
postcode_coordinaten.latitude AS `Breedtegraad`,
|
|
55
|
+
postcode_coordinaten.longitude AS `Lengtegraad`,
|
|
56
|
+
COUNT(DISTINCT leden.organization_id) AS `Aantal eenheden`
|
|
57
|
+
FROM leden
|
|
58
|
+
LEFT JOIN postcode_coordinaten ON postcode_coordinaten.postalCode = leden.eenheid_postcode
|
|
59
|
+
GROUP BY leden.eenheid_postcode, postcode_coordinaten.latitude, postcode_coordinaten.longitude
|
|
52
60
|
ORDER BY `Aantal eenheden` DESC
|
|
53
61
|
|
|
54
62
|
-- @card eenheden-per-netwerk
|
|
@@ -57,14 +65,18 @@ ORDER BY `Aantal eenheden` DESC
|
|
|
57
65
|
-- size: half
|
|
58
66
|
-- dimensions: Netwerk
|
|
59
67
|
-- metrics: Aantal eenheden
|
|
60
|
-
|
|
61
|
-
-- @include
|
|
68
|
+
WITH leden AS (
|
|
69
|
+
-- @include deduplicated-non-platform-registrations
|
|
70
|
+
)
|
|
62
71
|
SELECT
|
|
63
|
-
|
|
64
|
-
COUNT(DISTINCT
|
|
65
|
-
FROM leden
|
|
66
|
-
JOIN _organizations_organization_tags
|
|
67
|
-
ON
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
organization_tags.name AS `Netwerk`,
|
|
73
|
+
COUNT(DISTINCT leden.organization_id) AS `Aantal eenheden`
|
|
74
|
+
FROM leden
|
|
75
|
+
JOIN _organizations_organization_tags
|
|
76
|
+
ON _organizations_organization_tags.organizationsId = leden.organization_id
|
|
77
|
+
AND _organizations_organization_tags.periodId = leden.period_id
|
|
78
|
+
JOIN organization_tags
|
|
79
|
+
ON organization_tags.id = _organizations_organization_tags.organizationTagsId
|
|
80
|
+
AND organization_tags.periodId = _organizations_organization_tags.periodId
|
|
81
|
+
GROUP BY organization_tags.name
|
|
82
|
+
ORDER BY organization_tags.name
|
package/report/varia.sql
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
-- @tab varia
|
|
2
2
|
-- title: Varia
|
|
3
3
|
-- description: Kinderen en leiding per eenheid, uitgesplitst naar geslacht.
|
|
4
|
-
-- filters:
|
|
4
|
+
-- filters: werkjaar, platformleden_opnemen
|
|
5
|
+
-- required: werkjaar
|
|
5
6
|
|
|
6
7
|
-- @card uldk
|
|
7
8
|
-- title: ULDK
|
|
8
9
|
-- display: table
|
|
9
10
|
-- size: full
|
|
10
|
-
--
|
|
11
|
-
--
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
-- De tabel is het fragment zelf, enkel gesorteerd: wie het los van de kaart wil bekijken, opent de
|
|
12
|
+
-- snippet en draait ze zoals ze is.
|
|
13
|
+
SELECT * FROM (
|
|
14
|
+
-- @include uldk
|
|
15
|
+
) uldk
|
|
16
|
+
ORDER BY `Name`
|
|
14
17
|
|
|
15
18
|
-- @card uldk-totaal
|
|
16
19
|
-- title: ULDK (totaal)
|
|
@@ -18,9 +21,6 @@ SELECT * FROM uldk ORDER BY `Name`
|
|
|
18
21
|
-- size: full
|
|
19
22
|
-- height: 4
|
|
20
23
|
-- description: De som van de kolommen in de tabel hierboven. Staat in een eigen kaart omdat een tabel in Metabase enkel rijen bovenaan kan vastzetten: als laatste rij van de tabel zou het totaal pas na het doorscrollen van alle eenheden te zien zijn.
|
|
21
|
-
-- @include facts
|
|
22
|
-
-- @include leden
|
|
23
|
-
-- @include uldk
|
|
24
24
|
SELECT
|
|
25
25
|
'Totaal' AS `Name`,
|
|
26
26
|
'' AS `City`,
|
|
@@ -32,4 +32,6 @@ SELECT
|
|
|
32
32
|
COALESCE(SUM(`Aantal leiding/Vrouw`), 0) AS `Aantal leiding/Vrouw`,
|
|
33
33
|
COALESCE(SUM(`Aantal leiding/Andere`), 0) AS `Aantal leiding/Andere`,
|
|
34
34
|
COALESCE(SUM(`Aantal leiding/Onbekend`), 0) AS `Aantal leiding/Onbekend`
|
|
35
|
-
FROM
|
|
35
|
+
FROM (
|
|
36
|
+
-- @include uldk
|
|
37
|
+
) uldk
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
-- Whether the member of a registration was aangesloten in the year that registration belongs to: a
|
|
2
|
-
-- lidgeld recorded against that period which was not deleted again.
|
|
3
|
-
--
|
|
4
|
-
-- What the aanlevering counts as ingeschreven. Being registered at a group is not enough on its own:
|
|
5
|
-
-- a koepel delivers the deelnemers it aansluit, and a registration that never became an aansluiting
|
|
6
|
-
-- is a member of the group rather than of the jeugdbeweging.
|
|
7
|
-
--
|
|
8
|
-
-- Not deleted is the whole of what makes it count. A lidgeld whose expireDate has passed, or one that
|
|
9
|
-
-- never left its proefperiode, still says the member was aangesloten during that werkjaar, which is
|
|
10
|
-
-- the question the dataset asks -- not whether the koepel still holds them today.
|
|
11
|
-
--
|
|
12
|
-
-- Not to be confused with `aansluiting.sql`, the filter above the dashboards: that one narrows to the
|
|
13
|
-
-- types the reader picked and disappears when they pick none. This is a condition of the sheets
|
|
14
|
-
-- themselves and always holds.
|
|
15
|
-
--
|
|
16
|
-
-- Belongs in a WHERE clause on rows of `all_registrations`, `all_facts` or `facts` aliased as `f`.
|
|
17
|
-
EXISTS (
|
|
18
|
-
SELECT 1
|
|
19
|
-
FROM member_platform_memberships mpm
|
|
20
|
-
WHERE mpm.memberId = f.member_id
|
|
21
|
-
AND mpm.periodId = f.period_id
|
|
22
|
-
AND mpm.deletedAt IS NULL
|
|
23
|
-
)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
-- Which aansluiting a member holds, as the filter above the dashboards asks it: a registration counts
|
|
2
|
-
-- when its member holds one of the chosen types in the year that registration is in.
|
|
3
|
-
--
|
|
4
|
-
-- Nothing chosen drops the whole clause, which is what leaves every member in -- including everyone
|
|
5
|
-
-- holding no aansluiting at all. That is the state the dashboards open in.
|
|
6
|
-
--
|
|
7
|
-
-- `IN` rather than `=`, because several types can be chosen at once: Metabase writes a multi-value
|
|
8
|
-
-- filter out as the values it was given, comma separated.
|
|
9
|
-
--
|
|
10
|
-
-- On the name of the type rather than its id: a type holds a row per year under one id, and the name
|
|
11
|
-
-- is what the filter lists, the same way the scoutsjaar and the eenheid are filtered by name.
|
|
12
|
-
--
|
|
13
|
-
-- Where the aansluiting was recorded is deliberately not part of it. The koepel records one on its
|
|
14
|
-
-- own structuurvrijwilligers too, and `all_facts` is read by the sheet that counts exactly those,
|
|
15
|
-
-- which an organization condition here would empty.
|
|
16
|
-
--
|
|
17
|
-
-- Belongs in a WHERE clause that has the registration as `r`.
|
|
18
|
-
[[AND EXISTS (
|
|
19
|
-
SELECT 1
|
|
20
|
-
FROM member_platform_memberships mpm
|
|
21
|
-
JOIN platform_membership_types mt ON mt.id = mpm.membershipTypeId AND mt.periodId = mpm.periodId
|
|
22
|
-
WHERE mpm.memberId = r.memberId
|
|
23
|
-
AND mpm.periodId = r.periodId
|
|
24
|
-
AND mpm.deletedAt IS NULL
|
|
25
|
-
AND mt.name IN ({{aansluiting}})
|
|
26
|
-
)]]
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
-- The same grain as `facts`, but never filtered by scoutsjaar: the cards that draw a line across the
|
|
2
|
-
-- years need every year regardless of which one the dashboard filter has selected. Keep the two in
|
|
3
|
-
-- step when changing what counts as an active registration.
|
|
4
|
-
WITH
|
|
5
|
-
-- @include takken
|
|
6
|
-
facts AS (
|
|
7
|
-
SELECT
|
|
8
|
-
r.memberId AS member_id,
|
|
9
|
-
r.organizationId AS organization_id,
|
|
10
|
-
o.name AS `Eenheid`,
|
|
11
|
-
o.postalCode AS eenheid_postcode,
|
|
12
|
-
o.city AS eenheid_gemeente,
|
|
13
|
-
p.id AS period_id,
|
|
14
|
-
p.name AS `Scoutsjaar`,
|
|
15
|
-
p.startDate AS period_start,
|
|
16
|
-
g.type AS group_type,
|
|
17
|
-
COALESCE(dag.name, g.name) AS `Tak`,
|
|
18
|
-
dag.id AS tak_id,
|
|
19
|
-
dag.category AS tak_category,
|
|
20
|
-
dag.minAge AS tak_min_age,
|
|
21
|
-
dag.maxAge AS tak_max_age,
|
|
22
|
-
COALESCE(
|
|
23
|
-
dag.category,
|
|
24
|
-
CASE WHEN dag.maxAge < 18 THEN 'child' END,
|
|
25
|
-
CASE WHEN TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) < 18 THEN 'child' END
|
|
26
|
-
) AS effective_category,
|
|
27
|
-
CASE m.gender
|
|
28
|
-
WHEN 'Male' THEN 'Man'
|
|
29
|
-
WHEN 'Female' THEN 'Vrouw'
|
|
30
|
-
WHEN 'Other' THEN 'Andere'
|
|
31
|
-
ELSE 'Onbekend'
|
|
32
|
-
END AS `Geslacht`,
|
|
33
|
-
m.birthDate AS birth_date,
|
|
34
|
-
TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) AS leeftijd,
|
|
35
|
-
m.postalCode AS postcode
|
|
36
|
-
FROM registrations r
|
|
37
|
-
JOIN registration_periods p ON p.id = r.periodId
|
|
38
|
-
JOIN `groups` g ON g.id = r.groupId AND g.deletedAt IS NULL
|
|
39
|
-
-- The tak, the member and the eenheid are each recorded per year, so the period is part of what
|
|
40
|
-
-- identifies the row to join to: a tak that is renamed or a member who moves changes the year it
|
|
41
|
-
-- happened in, not every year they were ever counted in.
|
|
42
|
-
LEFT JOIN takken dag ON dag.id = g.defaultAgeGroupId AND dag.periodId = r.periodId
|
|
43
|
-
JOIN members m ON m.id = r.memberId AND m.periodId = r.periodId
|
|
44
|
-
JOIN organizations o ON o.id = r.organizationId AND o.periodId = r.periodId
|
|
45
|
-
WHERE r.deactivatedAt IS NULL
|
|
46
|
-
AND r.registeredAt IS NOT NULL
|
|
47
|
-
-- Not the koepel's own organization: it is the national body rather than an eenheid, and the
|
|
48
|
-
-- ledenstatistieken count none of its structuurvrijwilligers. See `facts.sql`.
|
|
49
|
-
AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = r.organizationId)
|
|
50
|
-
[[AND o.name = {{eenheid}}]]
|
|
51
|
-
-- @include aansluiting
|
|
52
|
-
-- @include ingeschreven-voor
|
|
53
|
-
)
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
-- One row per member per group per scoutsjaar: the grain every figure in the report is counted from.
|
|
2
|
-
--
|
|
3
|
-
-- The scoutsjaar is the period's name, not its id. A registration points at the period of its own
|
|
4
|
-
-- organization, and every organization holds its own row for the same year, so the id identifies a
|
|
5
|
-
-- unit's year rather than the year itself. The name is what those rows share, which makes it the
|
|
6
|
-
-- only thing a national figure can group on. Imported years are single platform-wide rows and fall
|
|
7
|
-
-- out of the same rule.
|
|
8
|
-
--
|
|
9
|
-
-- A registration counts when it is active: not cancelled and actually registered. A member in two
|
|
10
|
-
-- groups appears twice here, so member counts are always COUNT(DISTINCT).
|
|
11
|
-
--
|
|
12
|
-
-- Which kinds of group count is the reader's, through `ingeschreven-voor.sql`: the ledenstatistieken
|
|
13
|
-
-- open on the leeftijdsgroepen alone and can be asked for the activiteiten and the wachtlijsten
|
|
14
|
-
-- beside them. `group_type` carries what that filter reads, so a card that may not be asked -- the
|
|
15
|
-
-- aanlevering, which is about leden of a jeugdbeweging and about nothing else -- says so itself.
|
|
16
|
-
--
|
|
17
|
-
-- Two columns say what a registration counts as, and they answer different questions.
|
|
18
|
-
-- `tak_category` is what the tak counts as -- kinderen, leiding or volwassenen -- as `takken.sql`
|
|
19
|
-
-- decides it, and is null wherever nobody has said. The aanlevering reads that one, and so do the
|
|
20
|
-
-- figures that weigh leiding against kinderen: a sheet delivered to a department may not guess, and a
|
|
21
|
-
-- division with leiding on one side cannot lean on a fallback that reads every young leider as a
|
|
22
|
-
-- kind. `effective_category` is that same answer with the fallbacks the ledenstatistieken need behind
|
|
23
|
-
-- it -- the tak's age range, and then the member's own age at the start of the year -- so that nobody
|
|
24
|
-
-- drops out of a total for want of a tak that was never categorised.
|
|
25
|
-
--
|
|
26
|
-
-- That last fallback catches what the import could not name. The client's export leaves the tak empty
|
|
27
|
-
-- on the children of the years before 2020-2021; the import reads those from the member's age, except
|
|
28
|
-
-- where a date of birth puts them outside every tak. Without the fallback each of those few counts
|
|
29
|
-
-- towards the total while showing up in none of the three categories. The handful of adults among
|
|
30
|
-
-- them stay null, because nothing here tells leiding from volwassenen.
|
|
31
|
-
--
|
|
32
|
-
-- Three names for the same rows, each one dropping something the one before it keeps:
|
|
33
|
-
--
|
|
34
|
-
-- * `all_registrations` is every registration of the werkjaar, the ones that were cancelled during
|
|
35
|
-
-- it included. Only the aanlevering reads it: the department counts everyone who was registered
|
|
36
|
-
-- at some point between september and august, not who was still registered in august.
|
|
37
|
-
-- * `all_facts` keeps the ones that are still active, which is what the report means by a lid.
|
|
38
|
-
-- * `facts` is that without the koepel's own organization. Every figure of the ledenstatistieken
|
|
39
|
-
-- is counted from it, through `leden.sql`, which narrows it to one row per member.
|
|
40
|
-
WITH
|
|
41
|
-
-- @include takken
|
|
42
|
-
all_registrations AS (
|
|
43
|
-
SELECT
|
|
44
|
-
r.memberId AS member_id,
|
|
45
|
-
r.organizationId AS organization_id,
|
|
46
|
-
o.name AS `Eenheid`,
|
|
47
|
-
o.postalCode AS eenheid_postcode,
|
|
48
|
-
o.city AS eenheid_gemeente,
|
|
49
|
-
p.id AS period_id,
|
|
50
|
-
p.name AS `Scoutsjaar`,
|
|
51
|
-
p.startDate AS period_start,
|
|
52
|
-
g.type AS group_type,
|
|
53
|
-
COALESCE(dag.name, g.name) AS `Tak`,
|
|
54
|
-
dag.id AS tak_id,
|
|
55
|
-
dag.category AS tak_category,
|
|
56
|
-
dag.minAge AS tak_min_age,
|
|
57
|
-
dag.maxAge AS tak_max_age,
|
|
58
|
-
COALESCE(
|
|
59
|
-
dag.category,
|
|
60
|
-
CASE WHEN dag.maxAge < 18 THEN 'child' END,
|
|
61
|
-
CASE WHEN TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) < 18 THEN 'child' END
|
|
62
|
-
) AS effective_category,
|
|
63
|
-
CASE m.gender
|
|
64
|
-
WHEN 'Male' THEN 'Man'
|
|
65
|
-
WHEN 'Female' THEN 'Vrouw'
|
|
66
|
-
WHEN 'Other' THEN 'Andere'
|
|
67
|
-
ELSE 'Onbekend'
|
|
68
|
-
END AS `Geslacht`,
|
|
69
|
-
m.birthDate AS birth_date,
|
|
70
|
-
TIMESTAMPDIFF(YEAR, m.birthDate, p.startDate) AS leeftijd,
|
|
71
|
-
m.postalCode AS postcode,
|
|
72
|
-
r.deactivatedAt AS deactivated_at
|
|
73
|
-
FROM registrations r
|
|
74
|
-
JOIN registration_periods p ON p.id = r.periodId
|
|
75
|
-
JOIN `groups` g ON g.id = r.groupId AND g.deletedAt IS NULL
|
|
76
|
-
-- The tak, the member and the eenheid are each recorded per year, so the period is part of what
|
|
77
|
-
-- identifies the row to join to: a tak that is renamed or a member who moves changes the year it
|
|
78
|
-
-- happened in, not every year they were ever counted in.
|
|
79
|
-
LEFT JOIN takken dag ON dag.id = g.defaultAgeGroupId AND dag.periodId = r.periodId
|
|
80
|
-
JOIN members m ON m.id = r.memberId AND m.periodId = r.periodId
|
|
81
|
-
JOIN organizations o ON o.id = r.organizationId AND o.periodId = r.periodId
|
|
82
|
-
WHERE r.registeredAt IS NOT NULL
|
|
83
|
-
[[AND p.name = {{scoutsjaar}}]]
|
|
84
|
-
[[AND o.name = {{eenheid}}]]
|
|
85
|
-
-- @include aansluiting
|
|
86
|
-
-- @include ingeschreven-voor
|
|
87
|
-
),
|
|
88
|
-
-- Where a registration that was cancelled during the year drops out. It stays a registration of that
|
|
89
|
-
-- werkjaar -- someone who left in november was a lid of that year -- but it is no longer one of the
|
|
90
|
-
-- registrations the ledenstatistieken count, which are the ones that are still standing.
|
|
91
|
-
all_facts AS (
|
|
92
|
-
SELECT f.* FROM all_registrations f WHERE f.deactivated_at IS NULL
|
|
93
|
-
),
|
|
94
|
-
-- The koepel's own organization is not an eenheid: it is the national body, and the client's report
|
|
95
|
-
-- counts the structuurvrijwilligers of its ploegen as nobody's leden and nobody's leiding. Which
|
|
96
|
-
-- organization it is comes from `platform.membershipOrganizationId`, the only thing that says so --
|
|
97
|
-
-- the import writes the koepel under that same id, so the years it owns drop out here exactly as the
|
|
98
|
-
-- synced ones do.
|
|
99
|
-
facts AS (
|
|
100
|
-
SELECT f.* FROM all_facts f
|
|
101
|
-
WHERE NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = f.organization_id)
|
|
102
|
-
)
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
-- Which registrations are counted, as the filter above the dashboards asks it: a registration stands
|
|
2
|
-
-- in a group, and the reader picks which kinds of group say someone is a lid.
|
|
3
|
-
--
|
|
4
|
-
-- Three names for the three kinds a group can be. A leeftijdsgroep is a tak of the eenheid and is
|
|
5
|
-
-- what the ledenstatistieken are read as; an activiteit is a single event someone registered for, and
|
|
6
|
-
-- a wachtlijst is a place they are waiting for. The last two are registrations at an eenheid without
|
|
7
|
-
-- being a lid of it, which is why the filter opens on leeftijdsgroepen alone and the other two are
|
|
8
|
-
-- something a reader asks for.
|
|
9
|
-
--
|
|
10
|
-
-- Said in those words rather than on `g.type` itself, because the filter is a list a reader picks
|
|
11
|
-
-- from and 'EventRegistration' is not a word this report uses anywhere else. A type the CASE does not
|
|
12
|
-
-- name falls under no option and drops out until the report says what to call it: a new kind of group
|
|
13
|
-
-- is nobody's lid until someone has decided that it is.
|
|
14
|
-
--
|
|
15
|
-
-- Nothing chosen drops the whole clause and counts every registration, the way the aansluiting filter
|
|
16
|
-
-- does. No dashboard opens that way -- the filter starts on Leeftijdsgroepen -- so it is what a
|
|
17
|
-
-- reader who empties the filter asked for rather than a state they can land in.
|
|
18
|
-
--
|
|
19
|
-
-- The years imported from the client's own statistics carry the default of the column, which is what
|
|
20
|
-
-- those years are: an export of takken and nothing else.
|
|
21
|
-
--
|
|
22
|
-
-- Belongs in a WHERE clause that has the group as `g`.
|
|
23
|
-
[[AND CASE g.type
|
|
24
|
-
WHEN 'Membership' THEN 'Leeftijdsgroepen'
|
|
25
|
-
WHEN 'EventRegistration' THEN 'Activiteiten'
|
|
26
|
-
WHEN 'WaitingList' THEN 'Wachtlijsten'
|
|
27
|
-
END IN ({{ingeschreven_voor}})]]
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
-- Elk scoutsjaar met het scoutsjaar erna, waarin het ledenbehoud van dat jaar gemeten wordt. Een
|
|
2
|
-
-- scoutsjaar is de naam van de periode: elke eenheid houdt een eigen periode-rij voor hetzelfde jaar,
|
|
3
|
-
-- dus alleen de naam is over alle eenheden heen hetzelfde.
|
|
4
|
-
--
|
|
5
|
-
-- Het ledenbehoud hoort bij het jaar van de leden zelf, niet bij het jaar waarin ze terugkomen: naast
|
|
6
|
-
-- scoutsjaar N staat het percentage van de leden van N dat in N+1 nog lid was, zoals het rapport van
|
|
7
|
-
-- de klant het ook zet. Het laatste jaar heeft daardoor geen cijfer -- `volgend` is dan NULL -- en
|
|
8
|
-
-- moet uit elke kaart gefilterd worden, anders leest het als 0% ledenbehoud.
|
|
9
|
-
--
|
|
10
|
-
-- Alleen jaren met leden vormen de ketting. Een periode zonder leden -- een jaar dat nog niet
|
|
11
|
-
-- gesynchroniseerd is, of een eigen periode van een eenheid -- zou het jaar ervoor anders op 0%
|
|
12
|
-
-- ledenbehoud zetten, en het jaar zelf heeft leden nodig om er lid in te kunnen zijn.
|
|
13
|
-
--
|
|
14
|
-
-- Hoort na `leden-per-jaar`, waar het de jaren met leden uit haalt.
|
|
15
|
-
, jaren AS (
|
|
16
|
-
SELECT name, MIN(startDate) AS startDate, LEAD(name) OVER (ORDER BY MIN(startDate)) AS volgend
|
|
17
|
-
FROM registration_periods
|
|
18
|
-
WHERE name IN (SELECT `Scoutsjaar` FROM leden_per_jaar)
|
|
19
|
-
GROUP BY name
|
|
20
|
-
)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
-- Wie in welk scoutsjaar lid was, over het hele platform en zonder filters op wie meetelt.
|
|
2
|
-
--
|
|
3
|
-
-- Dit is de "is nog lid"-kant van het ledenbehoud. Een lid dat het jaar erna bij een andere eenheid
|
|
4
|
-
-- opduikt telt als blijver: zo rekent het rapport van de klant het ook. De cijfers van 9e Wandelaar
|
|
5
|
-
-- tonen het verschil — 38, 54 en 46 blijvers met deze telling, 37, 51 en 45 als alleen dezelfde
|
|
6
|
-
-- eenheid meetelt.
|
|
7
|
-
--
|
|
8
|
-
-- Bewust niet uit `facts` gehaald: die is gefilterd op de gekozen eenheid, en dan zou een lid dat
|
|
9
|
-
-- verhuist juist wel als vertrekker tellen.
|
|
10
|
-
--
|
|
11
|
-
-- Op één filter na. Waar iemand lid is doet er niet toe, wat voor inschrijving het is wel: als de
|
|
12
|
-
-- teller enkel leeftijdsgroepen telt en de noemer elke inschrijving, dan is wie vertrokken is maar
|
|
13
|
-
-- het jaar erna één activiteit meedoet een blijver. `ingeschreven-voor.sql` staat daarom aan beide
|
|
14
|
-
-- kanten van de breuk, zodat "is nog lid" hetzelfde betekent als "was lid".
|
|
15
|
-
, leden_per_jaar AS (
|
|
16
|
-
SELECT DISTINCT
|
|
17
|
-
r.memberId AS member_id,
|
|
18
|
-
p.name AS `Scoutsjaar`
|
|
19
|
-
FROM registrations r
|
|
20
|
-
JOIN registration_periods p ON p.id = r.periodId
|
|
21
|
-
JOIN `groups` g ON g.id = r.groupId AND g.deletedAt IS NULL
|
|
22
|
-
WHERE r.deactivatedAt IS NULL
|
|
23
|
-
AND r.registeredAt IS NOT NULL
|
|
24
|
-
-- Wie het jaar erna alleen nog bij de koepel zelf ingeschreven staat is geen blijver: dat is
|
|
25
|
-
-- dezelfde organisatie die `facts` weglaat, en een cijfer dat hier wel meetelt en daar niet zou
|
|
26
|
-
-- een ledenbehoud boven de leden zetten waar het over gaat.
|
|
27
|
-
AND NOT EXISTS (SELECT 1 FROM platform pf WHERE pf.membershipOrganizationId = r.organizationId)
|
|
28
|
-
-- @include ingeschreven-voor
|
|
29
|
-
)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
-- One row per member per eenheid per scoutsjaar: what someone is, decided once, before the figures
|
|
2
|
-
-- that weigh leiding against kinderen count them.
|
|
3
|
-
--
|
|
4
|
-
-- `facts` holds a row per registration, so a member registered in two takken of the same eenheid
|
|
5
|
-
-- stands in it twice. Counted as they stand there, someone who is leiding in one tak and lid in
|
|
6
|
-
-- another is counted as both -- in the omkaderingscijfer as a kind and as the leider they are
|
|
7
|
-
-- divided by at once -- and the GTP index weighs such a member in two of its terms. This picks the
|
|
8
|
-
-- one registration that says what they are, the way `jeugdbewegingen.sql` picks it for the
|
|
9
|
-
-- aanlevering: leiding beats lid, and between two takken the oldest one wins, since that is the one a
|
|
10
|
-
-- member has grown into. The name of the tak breaks a tie no age can, so that two runs of the same
|
|
11
|
-
-- query cannot pick differently.
|
|
12
|
-
--
|
|
13
|
-
-- What a member is comes from `tak_category`, what the tak was recorded as, and never from
|
|
14
|
-
-- `effective_category`, which falls back to the member's own age. That fallback cannot tell leiding
|
|
15
|
-
-- from anything, so a leider of sixteen would read as a kind and be counted on both sides of the same
|
|
16
|
-
-- division. It does decide between two rows that the takken leave equally unsaid, so that a member
|
|
17
|
-
-- whose only reading is the fallback keeps it rather than losing it to whichever row sorted first.
|
|
18
|
-
--
|
|
19
|
-
-- Every member keeps a row, whether their tak is categorised or not, and every row keeps both
|
|
20
|
-
-- columns: a card that counts kinderen the way the totals do goes on reading `effective_category`
|
|
21
|
-
-- here, and only counts a member once now.
|
|
22
|
-
--
|
|
23
|
-
-- Belongs after `facts` or `facts-alle-jaren`, whichever grain the card reads.
|
|
24
|
-
, leden AS (
|
|
25
|
-
SELECT g.* FROM (
|
|
26
|
-
SELECT
|
|
27
|
-
f.*,
|
|
28
|
-
ROW_NUMBER() OVER (
|
|
29
|
-
PARTITION BY f.organization_id, f.`Scoutsjaar`, f.member_id
|
|
30
|
-
ORDER BY
|
|
31
|
-
CASE f.tak_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
32
|
-
CASE f.effective_category WHEN 'leader' THEN 3 WHEN 'child' THEN 2 WHEN 'adult' THEN 1 ELSE 0 END DESC,
|
|
33
|
-
f.tak_min_age DESC,
|
|
34
|
-
f.`Tak`
|
|
35
|
-
) AS rang
|
|
36
|
-
FROM facts f
|
|
37
|
-
) g
|
|
38
|
-
WHERE g.rang = 1
|
|
39
|
-
)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
-- The omkaderingscijfer: how many children a leider looks after on average.
|
|
2
|
-
--
|
|
3
|
-
-- Aantal kinderen / Aantal leiding
|
|
4
|
-
--
|
|
5
|
-
-- Low is good, and from 10 upwards keeping an eye on everyone gets hard. Also the divisor of the GTP
|
|
6
|
-
-- index, which takes it from here unrounded -- only what reaches the screen is rounded here.
|
|
7
|
-
--
|
|
8
|
-
-- Counts the kinderen and the leiding of a categorised tak, so that nobody stands on both sides of
|
|
9
|
-
-- the division: someone who is leiding in one tak and lid in another is a leider here and not also
|
|
10
|
-
-- one of the children they look after. A member whose tak nobody has categorised is neither, and is
|
|
11
|
-
-- counted by the totals beside this rather than by the division -- which is why `Aantal kinderen`
|
|
12
|
-
-- divided by `Aantal leiding` off the same page can come out slightly higher.
|
|
13
|
-
--
|
|
14
|
-
-- Reads from `leden`, one row per member per eenheid, where that is decided.
|
|
15
|
-
ROUND(
|
|
16
|
-
COUNT(DISTINCT CASE WHEN tak_category = 'child' THEN member_id END)
|
|
17
|
-
/ NULLIF(COUNT(DISTINCT CASE WHEN tak_category = 'leader' THEN member_id END), 0), 2)
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
-- Where a postal code is, so Metabase can put a point on the map for it.
|
|
2
|
-
--
|
|
3
|
-
-- The maps attach this with a LEFT JOIN, because what members have in their postal code field is not
|
|
4
|
-
-- always a Belgian postal code: typos, a Dutch one, or a whole address typed into the box. Those
|
|
5
|
-
-- members keep counting towards the totals, they just get no pin. An INNER JOIN would drop them.
|
|
6
|
-
, postcode_coordinaten AS (
|
|
7
|
-
SELECT postalCode, latitude, longitude FROM postal_codes
|
|
8
|
-
)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
-- The omkaderingscijfer as ravot counts it: how many kinderen a leider looks after on average.
|
|
2
|
-
--
|
|
3
|
-
-- Aantal kinderen jonger dan 17 / Aantal leiding
|
|
4
|
-
--
|
|
5
|
-
-- The same figure as `../omkaderingscijfer.sql` on the same rows, over fewer kinderen: ravot reads
|
|
6
|
-
-- the age of a lid rather than the tak they are in, here as in `gtp.sql` beside it, and counts only
|
|
7
|
-
-- the kinderen that index weighs. Low is good, and from 10 upwards keeping an eye on everyone gets
|
|
8
|
-
-- hard. Also the divisor of the GTP index, which takes it from here unrounded -- only what reaches
|
|
9
|
-
-- the screen is rounded here.
|
|
10
|
-
--
|
|
11
|
-
-- `leeftijd` is the age at the start of the werkjaar, the age the rest of the report charts members
|
|
12
|
-
-- by. A kind of seventeen or older weighs in no term of the index and is outside this division too,
|
|
13
|
-
-- and a member whose date of birth is unknown has no age and falls outside it the same way.
|
|
14
|
-
--
|
|
15
|
-
-- Counts the kinderen and the leiding of a categorised tak, so that nobody stands on both sides of
|
|
16
|
-
-- the division: someone who is leiding in one tak and lid in another is a leider here and not also
|
|
17
|
-
-- one of the children they look after. A member whose tak nobody has categorised is neither, and is
|
|
18
|
-
-- counted by the totals beside this rather than by the division -- which is why `Aantal kinderen`
|
|
19
|
-
-- divided by `Aantal leiding` off the same page comes out higher: those totals count a kind by the
|
|
20
|
-
-- category of their tak, so they hold the kinderen of seventeen and over as well.
|
|
21
|
-
--
|
|
22
|
-
-- Reads from `leden`, one row per member per eenheid, where that is decided.
|
|
23
|
-
ROUND(
|
|
24
|
-
COUNT(DISTINCT CASE WHEN tak_category = 'child' AND leeftijd < 17 THEN member_id END)
|
|
25
|
-
/ NULLIF(COUNT(DISTINCT CASE WHEN tak_category = 'leader' THEN member_id END), 0), 2)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
-- The takken of ravot, by the id they carry in the platform configuration.
|
|
2
|
-
--
|
|
3
|
-
-- Said here rather than in a hand-filled column of the statistics database, for the reasons
|
|
4
|
-
-- `../tak-categorie.sql` gives. This is the whole answer, so a tak of ravot that is missing here
|
|
5
|
-
-- counts as nothing at all, and a tak added to the platform configuration has to be added here too.
|
|
6
|
-
--
|
|
7
|
-
-- The ondersteunende leden are volwassenen and may not be categorised as leiding: the
|
|
8
|
-
-- omkaderingscijfer and the GTP index would then read them as leiding that the kinderen of an eenheid
|
|
9
|
-
-- are looked after by. The aanlevering, which does deliver them among the leiding because the
|
|
10
|
-
-- department has no third word for them, names the tak itself instead -- see `type-deelnemers.sql`.
|
|
11
|
-
--
|
|
12
|
-
-- The two oldest takken of kinderen carry members of seventeen and over, which is what
|
|
13
|
-
-- `omkaderingscijfer.sql` means when it says the totals beside it hold those as well. They weigh in
|
|
14
|
-
-- no term of the GTP index, which stops at sixteen.
|
|
15
|
-
CASE dag.id
|
|
16
|
-
-- Kinderen
|
|
17
|
-
WHEN 'bd63a6ef-d4a1-497d-87a5-d7c36b4ad220' THEN 'child' -- Leeuwkes, Kabouters of Sloebers (6-8)
|
|
18
|
-
WHEN '23607074-624b-472f-926f-c719bb44e314' THEN 'child' -- Springers of Pagadders (8-10)
|
|
19
|
-
WHEN '5730f613-fb72-465b-b902-45b281a0e8b8' THEN 'child' -- Jongknapen, Roodkapjes of Joro's (10-12)
|
|
20
|
-
WHEN '3d56a0b2-9f4b-46ac-998b-d45a9b64cab2' THEN 'child' -- Knapen, Jimmers of Knimmers (12-14)
|
|
21
|
-
WHEN '03680919-689c-4df1-8976-bb71758cc025' THEN 'child' -- Sjo'ers, Simmers of Jonghernieuwers (14-16)
|
|
22
|
-
WHEN 'bed9b513-e0ff-4cc3-a0f3-1c021fc880a9' THEN 'child' -- +16, leiding in spe (16 en ouder)
|
|
23
|
-
WHEN '1ad6b686-d5fa-4168-8fa2-064d49f8c0e8' THEN 'child' -- Hernieuwers
|
|
24
|
-
-- Leiding
|
|
25
|
-
WHEN 'e3ec8d48-0d10-4f5d-9e50-dd3151c6666b' THEN 'leader' -- Leiding
|
|
26
|
-
-- Volwassenen
|
|
27
|
-
WHEN 'a28d290c-af71-4282-92cc-2224a18d3091' THEN 'adult' -- Ondersteunende leden
|
|
28
|
-
END AS category
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
-- What a deelnemer of a lokale groep is delivered as, as ravot counts it: the same as
|
|
2
|
-
-- `../type-deelnemers.sql` with the ondersteunende leden among the leiding.
|
|
3
|
-
--
|
|
4
|
-
-- Ondersteunende leden are volwassenen who carry a group rather than a tak of kinderen, and the
|
|
5
|
-
-- metadatafiche counts the volwassen begeleiders, kassabeheerders and secretarissen of a group as
|
|
6
|
-
-- leiding -- the department has no third word for them. The tak is not categorised as leiding, and
|
|
7
|
-
-- may not be: the omkaderingscijfer and the GTP index would then read it as leiding the kinderen of
|
|
8
|
-
-- an eenheid are looked after by. The aanlevering therefore names the tak itself.
|
|
9
|
-
--
|
|
10
|
-
-- Named by `tak_id`, the id of the row in `default_age_groups`, the way `gtp.sql` weighs the takken
|
|
11
|
-
-- it names: a name is what a tak carries per year, so a rename would stop delivering it in the year
|
|
12
|
-
-- it happened. The id is the one `tak-categorie.sql` beside this names it by.
|
|
13
|
-
--
|
|
14
|
-
-- A group an eenheid named `Ondersteunende leden` itself points at no tak, so it carries no id and is
|
|
15
|
-
-- delivered as neither. Under the name it was matched by before, such a group was delivered as
|
|
16
|
-
-- leiding.
|
|
17
|
-
CASE
|
|
18
|
-
WHEN f.tak_category = 'leader' THEN 2
|
|
19
|
-
WHEN f.tak_id = 'a28d290c-af71-4282-92cc-2224a18d3091' THEN 2 -- Ondersteunende leden
|
|
20
|
-
WHEN f.tak_category = 'child' THEN 1
|
|
21
|
-
ELSE 0
|
|
22
|
-
END
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
-- What a tak counts as -- kinderen, leiding or volwassenen -- for the platform reading the report.
|
|
2
|
-
--
|
|
3
|
-
-- Nothing in the administration knows it. The platform configuration has no such field, and the ages
|
|
4
|
-
-- do not answer it, since leiding and stam carry no age range and a tak of kinderen need not carry
|
|
5
|
-
-- one either. The statistics database does not hold it either: it kept a hand-filled `category`
|
|
6
|
-
-- column on `default_age_groups` until the reports began naming their takken themselves, and that
|
|
7
|
-
-- column is dropped.
|
|
8
|
-
--
|
|
9
|
-
-- So a platform says which of its takken are which here, in `includes/<env>/tak-categorie.sql`, which
|
|
10
|
-
-- is what `@include tak-categorie` expands to there. This unqualified one is what a platform that has
|
|
11
|
-
-- not is left with: nothing. That is not a failure -- the reports count a tak nobody has categorised
|
|
12
|
-
-- separately rather than guessing at it, and `effective_category` still reads the ages behind it so
|
|
13
|
-
-- that no kind drops out of a total -- but every figure dividing leiding from kinderen stays empty
|
|
14
|
-
-- until the list is written.
|
|
15
|
-
--
|
|
16
|
-
-- Belongs in the select list of the `takken` fragment, which has the row of `default_age_groups` as
|
|
17
|
-
-- `dag`. It is the column the rest of the report reads as `dag.category`.
|
|
18
|
-
CAST(NULL AS CHAR(16)) AS category
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
-- The takken every organization's groups map onto, as the report reads them: the rows of
|
|
2
|
-
-- `default_age_groups` with their category decided.
|
|
3
|
-
--
|
|
4
|
-
-- A fragment of its own because both grains of `facts` join it, and because it is where the one thing
|
|
5
|
-
-- about a tak that is neither synced nor derivable is settled -- see `tak-categorie.sql`. `category`
|
|
6
|
-
-- is no column of `default_age_groups`: it is added here, which is why the takken are read through
|
|
7
|
-
-- this rather than joined straight from the table. Everything downstream reads it as `dag`, so a
|
|
8
|
-
-- tak's name, ages and category are asked for the same way.
|
|
9
|
-
--
|
|
10
|
-
-- Belongs at the head of a `WITH`, and carries the comma to whatever CTE follows it.
|
|
11
|
-
takken AS (
|
|
12
|
-
SELECT
|
|
13
|
-
dag.id,
|
|
14
|
-
dag.periodId,
|
|
15
|
-
dag.name,
|
|
16
|
-
dag.minAge,
|
|
17
|
-
dag.maxAge,
|
|
18
|
-
-- @include tak-categorie
|
|
19
|
-
FROM default_age_groups dag
|
|
20
|
-
),
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
-- Het tarief waaraan een lidgeld is aangerekend: het standaardtarief, of het verlaagde tarief van de
|
|
2
|
-
-- koepel. Dat is wat de rapporten "type lidgeld" noemen -- de aansluiting zegt waarvoor iemand is
|
|
3
|
-
-- aangesloten, dit zegt wat ervoor betaald werd.
|
|
4
|
-
--
|
|
5
|
-
-- De naam van het verlaagde tarief is die van de koepel zelf (SOMkort, kansentarief). Ze staat op de
|
|
6
|
-
-- platformrij, want alleen het platform zelf weet hoe het dat tarief noemt. Er is één zo'n rij, dus
|
|
7
|
-
-- de subquery levert één naam; een platform dat er geen naam aan geeft valt terug op de bewoording
|
|
8
|
-
-- hier, en een databank waarin nog niets gesynchroniseerd is ook.
|
|
9
|
-
--
|
|
10
|
-
-- Hoort bij een query die de lidgelden als `mpm` heeft.
|
|
11
|
-
CASE WHEN mpm.reducedPrice = 1
|
|
12
|
-
THEN COALESCE((SELECT pf.reducedPriceName FROM platform pf WHERE pf.reducedPriceName IS NOT NULL LIMIT 1), 'Verlaagd tarief')
|
|
13
|
-
ELSE 'Standaardtarief'
|
|
14
|
-
END
|