Revision 1183
Added by Aaron Marcuse-Kubitza almost 13 years ago
inputs/SALVIAS/verify.sql | ||
---|---|---|
1 | 1 |
SELECT '# projects' AS ___; |
2 | 2 |
SELECT count(*) AS count |
3 | 3 |
FROM project |
4 |
JOIN party ON party_id = datasource_id |
|
5 |
WHERE organizationname = :datasource |
|
4 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource |
|
6 | 5 |
; |
7 | 6 |
|
8 | 7 |
SELECT 'projects' AS ___; |
9 | 8 |
SELECT projectname AS project |
10 | 9 |
FROM project |
11 |
JOIN party ON party_id = datasource_id |
|
12 |
WHERE organizationname = :datasource |
|
10 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource |
|
13 | 11 |
ORDER BY project |
14 | 12 |
; |
15 | 13 |
|
16 | 14 |
SELECT E'each project\'s # locations' AS ___; |
17 | 15 |
SELECT projectname AS project, count(*) AS locations_count |
18 | 16 |
FROM project |
19 |
JOIN party ON party_id = datasource_id |
|
17 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource
|
|
20 | 18 |
JOIN locationevent USING (project_id) |
21 |
WHERE organizationname = :datasource |
|
22 | 19 |
GROUP BY project |
23 | 20 |
ORDER BY project |
24 | 21 |
; |
... | ... | |
26 | 23 |
SELECT '# locations' AS ___; |
27 | 24 |
SELECT count(DISTINCT location_id) AS count |
28 | 25 |
FROM locationevent |
29 |
JOIN party ON party_id = datasource_id |
|
30 |
WHERE organizationname = :datasource |
|
31 |
AND parent_id IS NULL -- no subplots |
|
26 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource |
|
27 |
WHERE parent_id IS NULL -- no subplots |
|
32 | 28 |
; |
33 | 29 |
|
34 | 30 |
SELECT '# location events' AS ___; |
35 | 31 |
SELECT count(*) AS count |
36 | 32 |
FROM locationevent |
37 |
JOIN party ON party_id = datasource_id |
|
38 |
WHERE organizationname = :datasource |
|
33 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource |
|
39 | 34 |
AND parent_id IS NULL -- no subplots |
40 | 35 |
; |
41 | 36 |
|
... | ... | |
44 | 39 |
projectname AS project |
45 | 40 |
, method.name AS method |
46 | 41 |
FROM project |
47 |
JOIN party ON party_id = datasource_id |
|
42 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource
|
|
48 | 43 |
JOIN locationevent USING (project_id) |
49 | 44 |
JOIN method USING (method_id) |
50 |
WHERE organizationname = :datasource |
|
51 | 45 |
ORDER BY project, method |
52 | 46 |
LIMIT 10; |
53 | 47 |
|
... | ... | |
56 | 50 |
projectname AS project |
57 | 51 |
, method.observationmeasure AS observationmeasure |
58 | 52 |
FROM project |
59 |
JOIN party ON party_id = datasource_id |
|
53 |
JOIN party ON party_id = datasource_id AND organizationname = :datasource
|
|
60 | 54 |
JOIN locationevent USING (project_id) |
61 | 55 |
JOIN method USING (method_id) |
62 |
WHERE organizationname = :datasource |
|
63 | 56 |
ORDER BY project, observationmeasure |
64 | 57 |
LIMIT 10; |
Also available in: Unified diff
inputs/SALVIAS/verify.sql: When filtering by datasource name, use an AND clause in the JOIN party's ON condition instead of a separate WHERE statement, so that the datasource filtering code is all on the same line