Revision 12634
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/validation/aggregating/plots/bien3_validations_salvias_vegbien.sql | ||
---|---|---|
36 | 36 |
-- _plots_03_count_of_all_plots_in_this_source |
37 | 37 |
SELECT count(*) AS plots |
38 | 38 |
FROM (((plot l |
39 |
JOIN locationevent le ON ((l.location_id = le.location_id)))
|
|
39 |
JOIN locationevent le ON ((l.plot_id = le.location_id)))
|
|
40 | 40 |
JOIN project p ON ((p.project_id = le.project_id))) |
41 | 41 |
JOIN source s ON ((p.source_id = s.source_id))) |
42 | 42 |
WHERE (s.shortname = :datasource::text); |
43 | 43 |
|
44 | 44 |
-- _plots_04_count_of_plots_in_each_project_in_this_source |
45 | 45 |
SELECT p.projectname AS project_name, |
46 |
count(DISTINCT l.location_id) AS plots
|
|
46 |
count(DISTINCT l.plot_id) AS plots
|
|
47 | 47 |
FROM (((plot l |
48 |
JOIN locationevent le ON ((l.location_id = le.location_id)))
|
|
48 |
JOIN locationevent le ON ((l.plot_id = le.location_id)))
|
|
49 | 49 |
JOIN project p ON ((p.project_id = le.project_id))) |
50 | 50 |
JOIN source s ON ((p.source_id = s.source_id))) |
51 | 51 |
WHERE (s.shortname = :datasource::text) |
... | ... | |
55 | 55 |
SELECT p.projectname AS project_name, |
56 | 56 |
l.authorlocationcode AS plot_code |
57 | 57 |
FROM (((plot l |
58 |
JOIN locationevent le ON ((l.location_id = le.location_id)))
|
|
58 |
JOIN locationevent le ON ((l.plot_id = le.location_id)))
|
|
59 | 59 |
JOIN project p ON ((p.project_id = le.project_id))) |
60 | 60 |
JOIN source s ON ((p.source_id = s.source_id))) |
61 | 61 |
WHERE (s.shortname = :datasource::text); |
... | ... | |
64 | 64 |
SELECT project.projectname AS project_name, |
65 | 65 |
plot.authorlocationcode AS plot_code |
66 | 66 |
FROM ((plot |
67 |
JOIN locationevent USING (location_id))
|
|
67 |
JOIN locationevent USING (plot_id))
|
|
68 | 68 |
LEFT JOIN project USING (project_id)) |
69 | 69 |
WHERE ((plot.source_id = ( SELECT source_by_shortname(:datasource::text) AS source_by_shortname)) AND (EXISTS ( SELECT NULL::unknown AS unknown |
70 | 70 |
FROM (((((location |
... | ... | |
73 | 73 |
JOIN aggregateoccurrence USING (taxonoccurrence_id)) |
74 | 74 |
JOIN plantobservation USING (aggregateoccurrence_id)) |
75 | 75 |
JOIN stemobservation USING (plantobservation_id)) |
76 |
WHERE (location.plot_location_id = plot.location_id)
|
|
76 |
WHERE ((location.plot_location_id = plot.plot_id) AND ((stemobservation.sourceaccessioncode IS NOT NULL) OR (stemobservation.authorstemcode IS NOT NULL)))
|
|
77 | 77 |
LIMIT 1))) |
78 | 78 |
ORDER BY plot.authorlocationcode; |
79 | 79 |
|
... | ... | |
105 | 105 |
JOIN source s ON ((p.source_id = s.source_id))) |
106 | 106 |
JOIN place_visit ON ((p.project_id = place_visit.project_id))) |
107 | 107 |
JOIN locationevent le ON ((place_visit.locationevent_id = le.place_visit_id))) |
108 |
JOIN plot l ON ((place_visit.location_id = l.location_id)))
|
|
108 |
JOIN plot l ON ((place_visit.location_id = l.plot_id)))
|
|
109 | 109 |
JOIN taxonoccurrence o ON ((le.locationevent_id = o.locationevent_id))) |
110 | 110 |
JOIN aggregateoccurrence ao ON ((o.taxonoccurrence_id = ao.taxonoccurrence_id))) |
111 | 111 |
WHERE (s.shortname = :datasource::text) |
... | ... | |
126 | 126 |
JOIN source s ON ((p.source_id = s.source_id))) |
127 | 127 |
JOIN place_visit ON ((p.project_id = place_visit.project_id))) |
128 | 128 |
JOIN locationevent le ON ((place_visit.locationevent_id = le.place_visit_id))) |
129 |
JOIN plot l ON ((place_visit.location_id = l.location_id)))
|
|
129 |
JOIN plot l ON ((place_visit.location_id = l.plot_id)))
|
|
130 | 130 |
JOIN taxonoccurrence o ON ((le.locationevent_id = o.locationevent_id))) |
131 | 131 |
JOIN aggregateoccurrence ao ON ((o.taxonoccurrence_id = ao.taxonoccurrence_id))) |
132 | 132 |
WHERE (s.shortname = :datasource::text) |
... | ... | |
143 | 143 |
JOIN source s ON ((p.source_id = s.source_id))) |
144 | 144 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
145 | 145 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
146 |
JOIN plot l ON ((le.location_id = l.location_id)))
|
|
146 |
JOIN plot l ON ((le.location_id = l.plot_id)))
|
|
147 | 147 |
JOIN taxonoccurrence o ON ((sub_locationevent.locationevent_id = o.locationevent_id))) |
148 | 148 |
JOIN aggregateoccurrence ao ON ((o.taxonoccurrence_id = ao.taxonoccurrence_id))) |
149 | 149 |
JOIN plantobservation po ON ((po.aggregateoccurrence_id = ao.aggregateoccurrence_id))) |
... | ... | |
163 | 163 |
JOIN source s ON ((p.source_id = s.source_id))) |
164 | 164 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
165 | 165 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
166 |
JOIN plot l ON ((le.location_id = l.location_id)))
|
|
166 |
JOIN plot l ON ((le.location_id = l.plot_id)))
|
|
167 | 167 |
JOIN taxonoccurrence o ON ((sub_locationevent.locationevent_id = o.locationevent_id))) |
168 | 168 |
JOIN taxondetermination td ON ((td.taxonoccurrence_id = o.taxonoccurrence_id))) |
169 | 169 |
JOIN taxonverbatim tv ON ((td.taxonverbatim_id = tv.taxonverbatim_id))) |
... | ... | |
184 | 184 |
JOIN source s ON ((p.source_id = s.source_id))) |
185 | 185 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
186 | 186 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
187 |
JOIN plot l ON ((le.location_id = l.location_id)))
|
|
187 |
JOIN plot l ON ((le.location_id = l.plot_id)))
|
|
188 | 188 |
JOIN taxonoccurrence o ON ((sub_locationevent.locationevent_id = o.locationevent_id))) |
189 | 189 |
JOIN taxondetermination td ON ((td.taxonoccurrence_id = o.taxonoccurrence_id))) |
190 | 190 |
JOIN taxonverbatim tv ON ((td.taxonverbatim_id = tv.taxonverbatim_id))) |
... | ... | |
203 | 203 |
JOIN source s ON ((p.source_id = s.source_id))) |
204 | 204 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
205 | 205 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
206 |
JOIN plot l ON ((le.location_id = l.location_id)))
|
|
206 |
JOIN plot l ON ((le.location_id = l.plot_id)))
|
|
207 | 207 |
JOIN taxonoccurrence o ON ((sub_locationevent.locationevent_id = o.locationevent_id))) |
208 | 208 |
JOIN taxondetermination td ON ((td.taxonoccurrence_id = o.taxonoccurrence_id))) |
209 | 209 |
JOIN taxonverbatim tv ON ((td.taxonverbatim_id = tv.taxonverbatim_id))) |
... | ... | |
224 | 224 |
JOIN source s ON ((p.source_id = s.source_id))) |
225 | 225 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
226 | 226 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
227 |
JOIN plot l ON ((le.location_id = l.location_id)))
|
|
227 |
JOIN plot l ON ((le.location_id = l.plot_id)))
|
|
228 | 228 |
JOIN taxonoccurrence o ON ((sub_locationevent.locationevent_id = o.locationevent_id))) |
229 | 229 |
JOIN taxondetermination td ON ((td.taxonoccurrence_id = o.taxonoccurrence_id))) |
230 | 230 |
JOIN taxonverbatim tv ON ((td.taxonverbatim_id = tv.taxonverbatim_id))) |
... | ... | |
262 | 262 |
JOIN source s ON ((p.source_id = s.source_id))) |
263 | 263 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
264 | 264 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
265 |
JOIN plot l ON ((le.location_id = l.location_id)))
|
|
265 |
JOIN plot l ON ((le.location_id = l.plot_id)))
|
|
266 | 266 |
WHERE (s.shortname = :datasource::text) |
267 | 267 |
GROUP BY p.projectname, l.authorlocationcode |
268 | 268 |
ORDER BY p.projectname, l.authorlocationcode; |
... | ... | |
275 | 275 |
JOIN source s ON ((p.source_id = s.source_id))) |
276 | 276 |
JOIN locationevent le ON ((p.project_id = le.project_id))) |
277 | 277 |
JOIN locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id))) |
278 |
JOIN plot l ON ((sub_locationevent.location_id = l.location_id)))
|
|
278 |
JOIN plot l ON ((sub_locationevent.location_id = l.plot_id)))
|
|
279 | 279 |
WHERE (s.shortname = :datasource::text) |
280 | 280 |
ORDER BY p.projectname, l.authorlocationcode; |
281 | 281 |
/* |
Also available in: Unified diff
validation/aggregating/plots/bien3_validations_salvias_vegbien.sql: updated to DB