Project

General

Profile

« Previous | Next » 

Revision 12608

validation/aggregating/plots/bien3_validations_salvias_vegbien.sql: removed `CREATE OR REPLACE VIEW` so the validations views are not unintentionally replaced when running this file

View differences:

trunk/validation/aggregating/plots/bien3_validations_salvias_vegbien.sql
20 20

  
21 21
SET search_path TO public_validations, public;
22 22

  
23
CREATE OR REPLACE VIEW _plots_01_count_of_projects AS
23
-- _plots_01_count_of_projects
24 24
 SELECT count(*) AS projects
25 25
   FROM (project p
26 26
   JOIN source s ON ((p.source_id = s.source_id)))
27 27
  WHERE (s.shortname = ("current_schema"())::text);
28 28

  
29
CREATE OR REPLACE VIEW _plots_02_list_of_project_names AS
29
-- _plots_02_list_of_project_names
30 30
 SELECT p.projectname AS project_name
31 31
   FROM (project p
32 32
   JOIN source s ON ((p.source_id = s.source_id)))
33 33
  WHERE (s.shortname = ("current_schema"())::text);
34 34

  
35
CREATE OR REPLACE VIEW _plots_03_count_of_all_plots_in_this_source AS
35
-- _plots_03_count_of_all_plots_in_this_source
36 36
 SELECT count(*) AS plots
37 37
   FROM (((plot l
38 38
   JOIN locationevent le ON ((l.location_id = le.location_id)))
......
40 40
   JOIN source s ON ((p.source_id = s.source_id)))
41 41
  WHERE (s.shortname = ("current_schema"())::text);
42 42

  
43
CREATE OR REPLACE VIEW _plots_04_count_of_plots_in_each_project_in_this_source AS
43
-- _plots_04_count_of_plots_in_each_project_in_this_source
44 44
 SELECT p.projectname AS project_name, 
45 45
    count(DISTINCT l.location_id) AS plots
46 46
   FROM (((plot l
......
50 50
  WHERE (s.shortname = ("current_schema"())::text)
51 51
  GROUP BY p.projectname;
52 52

  
53
CREATE OR REPLACE VIEW _plots_05_list_of_plot_codes_by_project AS
53
-- _plots_05_list_of_plot_codes_by_project
54 54
 SELECT p.projectname AS project_name, 
55 55
    l.authorlocationcode AS plot_code
56 56
   FROM (((plot l
......
59 59
   JOIN source s ON ((p.source_id = s.source_id)))
60 60
  WHERE (s.shortname = ("current_schema"())::text);
61 61

  
62
CREATE OR REPLACE VIEW _plots_06_list_of_plots_with_stem_measurements AS
62
-- _plots_06_list_of_plots_with_stem_measurements
63 63
 SELECT project.projectname AS project_name, 
64 64
    plot.authorlocationcode AS plot_code
65 65
   FROM ((plot
......
79 79
-- ------------------
80 80
-- 7.List of plots with counts of individuals per species
81 81
-- ------------------
82
CREATE OR REPLACE VIEW _plots_07_list_of_plots_with_counts_of_individuals_per_species AS
82
-- _plots_07_list_of_plots_with_counts_of_individuals_per_species
83 83

  
84 84

  
85 85

  
86 86
-- ------------------
87 87
-- 8.List of plots which use percent cover
88 88
-- ------------------
89
CREATE OR REPLACE VIEW _plots_08_list_of_plots_which_use_percent_cover AS
89
-- _plots_08_list_of_plots_which_use_percent_cover
90 90

  
91 91

  
92 92

  
......
94 94
-- ------------------
95 95
-- 9.List of plots which use line-intercept
96 96
-- ------------------
97
CREATE OR REPLACE VIEW _plots_09_list_of_plots_which_use_line_intercept AS
97
-- _plots_09_list_of_plots_which_use_line_intercept
98 98

  
99
CREATE OR REPLACE VIEW _plots_10_count_of_individuals_per_plot_in_each_project AS
99
-- _plots_10_count_of_individuals_per_plot_in_each_project
100 100
 SELECT p.projectname AS project_name, 
101 101
    l.authorlocationcode AS plot_code, 
102 102
    sum(ao.count) AS individuals
......
116 116
Note 2: Does this method requires that plots have 2-level nesting of subplots within plots?
117 117
*/
118 118

  
119
CREATE OR REPLACE VIEW _plots_10a_aggregate_observation_individual_counts AS
119
-- _plots_10a_aggregate_observation_individual_counts
120 120
 SELECT p.projectname AS project_name, 
121 121
    l.authorlocationcode AS plot_code, 
122 122
    o.sourceaccessioncode AS individual_id, 
......
134 134
Note 1: `individuals` should be NULL for plots which use percent cover or line-intercept methods.
135 135
*/
136 136

  
137
CREATE OR REPLACE VIEW _plots_11_count_of_stems_per_plot_in_each_project AS
137
-- _plots_11_count_of_stems_per_plot_in_each_project
138 138
 SELECT p.projectname AS project_name, 
139 139
    l.authorlocationcode AS plot_code, 
140 140
    count(DISTINCT so.stemobservation_id) AS stems
......
154 154
Method: count records in stemobservation table
155 155
*/
156 156

  
157
CREATE OR REPLACE VIEW _plots_12_count_of_verbatim_taxa_per_plot_in_each_project AS
157
-- _plots_12_count_of_verbatim_taxa_per_plot_in_each_project
158 158
 SELECT p.projectname AS project_name, 
159 159
    l.authorlocationcode AS plot_code, 
160 160
    count(DISTINCT btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text)))) AS taxa
......
175 175
NOT YET READY, NEED TO INCLUDE SUBSPECIES, IF ANY
176 176
*/
177 177

  
178
CREATE OR REPLACE VIEW _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p AS
178
-- _plots_13_list_of_distinct_verbatim_taxa_in_each_plot_in_each_p
179 179
 SELECT DISTINCT p.projectname AS project_name, 
180 180
    l.authorlocationcode AS plot_code, 
181 181
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon
......
193 193
Note: Must perform equivalent concatenation of taxonomic field in source db.
194 194
*/
195 195

  
196
CREATE OR REPLACE VIEW _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr AS
196
-- _plots_14_count_of_indiv_per_verbatim_taxon_per_plot_in_each_pr
197 197
 SELECT DISTINCT p.projectname AS project_name, 
198 198
    l.authorlocationcode AS plot_code, 
199 199
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
......
214 214
Note: Must do equivalent concatenation of taxonomic field in source db.
215 215
*/
216 216

  
217
CREATE OR REPLACE VIEW _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro AS
217
-- _plots_15_pct_cover_of_each_verb_taxon_in_each_plot_in_each_pro
218 218
 SELECT DISTINCT p.projectname AS project_name, 
219 219
    l.authorlocationcode AS plot_code, 
220 220
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
......
251 251
--       stratum) with plots without subplots or strata (one cover measure 
252 252
--       per species per plot.
253 253
-- ------------------
254
CREATE OR REPLACE VIEW _plots_16_intercepts_for_each_verb_taxon_in_each_plot_in_each_project AS
254
-- _plots_16_intercepts_for_each_verb_taxon_in_each_plot_in_each_project
255 255

  
256
CREATE OR REPLACE VIEW _plots_17_count_of_subplots_per_plot_for_each_project AS
256
-- _plots_17_count_of_subplots_per_plot_for_each_project
257 257
 SELECT p.projectname AS project_name, 
258 258
    l.authorlocationcode AS plot_code, 
259 259
    count(DISTINCT sub_locationevent.locationevent_id) AS subplots
......
266 266
  GROUP BY p.projectname, l.authorlocationcode
267 267
  ORDER BY p.projectname, l.authorlocationcode;
268 268

  
269
CREATE OR REPLACE VIEW _plots_18_list_of_subplots_codes_for_each_plot_for_each_project AS
269
-- _plots_18_list_of_subplots_codes_for_each_plot_for_each_project
270 270
 SELECT p.projectname AS project_name, 
271 271
    l.authorlocationcode AS plot_code, 
272 272
    sub_locationevent.authoreventcode AS subplot_code

Also available in: Unified diff