Project

General

Profile

« Previous | Next » 

Revision 13063

schemas/vegbien.sql: public_validations: added specimens queries to pipeline

View differences:

vegbien.sql
8172 8172

  
8173 8173

  
8174 8174
--
8175
-- Name: VIEW _specimens_01_count_of_total_records_specimens_in_source_db; Type: COMMENT; Schema: public_validations; Owner: -
8176
--
8177

  
8178
COMMENT ON VIEW _specimens_01_count_of_total_records_specimens_in_source_db IS '
8179
Note: character set issues may cause mis-matches. This query is a good way to reveal character set issues, either in source db or in BIEN
8180
';
8181

  
8182

  
8183
--
8184
-- Name: _specimens_02_count_of_unique_verbatim_families; Type: VIEW; Schema: public_validations; Owner: -
8185
--
8186

  
8187
CREATE VIEW _specimens_02_count_of_unique_verbatim_families AS
8188
 SELECT count(DISTINCT taxonverbatim.family) AS families
8189
   FROM public.taxonverbatim
8190
  WHERE ((taxonverbatim.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonverbatim.family IS NOT NULL));
8191

  
8192

  
8193
--
8194
-- Name: _specimens_03_list_of_verbatim_families; Type: VIEW; Schema: public_validations; Owner: -
8195
--
8196

  
8197
CREATE VIEW _specimens_03_list_of_verbatim_families AS
8198
 SELECT DISTINCT taxonverbatim.family
8199
   FROM public.taxonverbatim
8200
  WHERE ((taxonverbatim.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonverbatim.family IS NOT NULL));
8201

  
8202

  
8203
--
8204
-- Name: _specimens_04_count_of_species_binomials; Type: VIEW; Schema: public_validations; Owner: -
8205
--
8206

  
8207
CREATE VIEW _specimens_04_count_of_species_binomials AS
8208
 SELECT count(DISTINCT concat_ws(' '::text, taxonverbatim.genus, taxonverbatim.specific_epithet)) AS species_binomials
8209
   FROM public.taxonverbatim
8210
  WHERE (((taxonverbatim.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonverbatim.genus IS NOT NULL)) AND (taxonverbatim.specific_epithet IS NOT NULL));
8211

  
8212

  
8213
--
8214
-- Name: _specimens_05_list_of_species_binomials; Type: VIEW; Schema: public_validations; Owner: -
8215
--
8216

  
8217
CREATE VIEW _specimens_05_list_of_species_binomials AS
8218
 SELECT DISTINCT concat_ws(' '::text, taxonverbatim.genus, taxonverbatim.specific_epithet) AS species_binomial
8219
   FROM public.taxonverbatim
8220
  WHERE (((taxonverbatim.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonverbatim.genus IS NOT NULL)) AND (taxonverbatim.specific_epithet IS NOT NULL));
8221

  
8222

  
8223
--
8224
-- Name: _specimens_06_count_of_unique_verb_subsp_taxa_with_author; Type: VIEW; Schema: public_validations; Owner: -
8225
--
8226

  
8227
CREATE VIEW _specimens_06_count_of_unique_verb_subsp_taxa_with_author AS
8228
 SELECT count(DISTINCT taxonlabel.taxonomicname) AS taxon_names_with_author
8229
   FROM public.taxonlabel
8230
  WHERE ((taxonlabel.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonlabel.taxonomicname IS NOT NULL));
8231

  
8232

  
8233
--
8234
-- Name: _specimens_07_list_of_verbatim_subspecific_taxa_with_author; Type: VIEW; Schema: public_validations; Owner: -
8235
--
8236

  
8237
CREATE VIEW _specimens_07_list_of_verbatim_subspecific_taxa_with_author AS
8238
 SELECT DISTINCT taxonlabel.taxonomicname AS taxon_name_with_author
8239
   FROM public.taxonlabel
8240
  WHERE ((taxonlabel.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonlabel.taxonomicname IS NOT NULL));
8241

  
8242

  
8243
--
8244
-- Name: _specimens_08_count_of_unique_verbatim_author_taxa_with_genus; Type: VIEW; Schema: public_validations; Owner: -
8245
--
8246

  
8247
CREATE VIEW _specimens_08_count_of_unique_verbatim_author_taxa_with_genus AS
8248
 SELECT count(DISTINCT taxonlabel.taxonomicname) AS taxon_names_with_author
8249
   FROM (public.taxonverbatim
8250
   JOIN public.taxonlabel USING (taxonlabel_id))
8251
  WHERE ((taxonverbatim.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonverbatim.genus IS NOT NULL));
8252

  
8253

  
8254
--
8255
-- Name: _specimens_09_list_of_unique_verbatim_author_taxa_with_genus; Type: VIEW; Schema: public_validations; Owner: -
8256
--
8257

  
8258
CREATE VIEW _specimens_09_list_of_unique_verbatim_author_taxa_with_genus AS
8259
 SELECT DISTINCT taxonlabel.taxonomicname AS taxon_name_with_author
8260
   FROM (public.taxonverbatim
8261
   JOIN public.taxonlabel USING (taxonlabel_id))
8262
  WHERE ((taxonverbatim.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (taxonverbatim.genus IS NOT NULL));
8263

  
8264

  
8265
--
8266
-- Name: _specimens_10_count_number_of_records_by_institution; Type: VIEW; Schema: public_validations; Owner: -
8267
--
8268

  
8269
CREATE VIEW _specimens_10_count_number_of_records_by_institution AS
8270
 SELECT specimenreplicate.duplicate_institutions_sourcelist_id AS specimen_duplicate_institutions, 
8271
    count(*) AS records
8272
   FROM public.specimenreplicate
8273
  WHERE (specimenreplicate.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname))
8274
  GROUP BY specimenreplicate.duplicate_institutions_sourcelist_id;
8275

  
8276

  
8277
--
8278
-- Name: _specimens_11_list_of_three_standard_political_divisions; Type: VIEW; Schema: public_validations; Owner: -
8279
--
8280

  
8281
CREATE VIEW _specimens_11_list_of_three_standard_political_divisions AS
8282
 SELECT DISTINCT place.country, 
8283
    place.stateprovince, 
8284
    place.county
8285
   FROM public.place
8286
  WHERE (place.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname));
8287

  
8288

  
8289
--
8290
-- Name: _specimens_12_distinct_collector_name_collect_num_date_w_count; Type: VIEW; Schema: public_validations; Owner: -
8291
--
8292

  
8293
CREATE VIEW _specimens_12_distinct_collector_name_collect_num_date_w_count AS
8294
 SELECT ( SELECT party.fullname
8295
           FROM public.party
8296
          WHERE (party.party_id = taxonoccurrence.collector_id)) AS "collectorName", 
8297
    specimenreplicate.collectionnumber AS "collectionNumber", 
8298
    aggregateoccurrence.collectiondate AS "dateCollected", 
8299
    count(*) AS "specimenRecords"
8300
   FROM (((public.taxonoccurrence
8301
   JOIN public.aggregateoccurrence USING (taxonoccurrence_id))
8302
   JOIN public.plantobservation USING (aggregateoccurrence_id))
8303
   JOIN public.specimenreplicate USING (plantobservation_id))
8304
  WHERE (taxonoccurrence.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname))
8305
  GROUP BY ( SELECT party.fullname
8306
   FROM public.party
8307
  WHERE (party.party_id = taxonoccurrence.collector_id)), specimenreplicate.collectionnumber, aggregateoccurrence.collectiondate
8308
  ORDER BY ( SELECT party.fullname
8309
   FROM public.party
8310
  WHERE (party.party_id = taxonoccurrence.collector_id)), specimenreplicate.collectionnumber, aggregateoccurrence.collectiondate;
8311

  
8312

  
8313
--
8314
-- Name: _specimens_13_count_of_all_verbatim_and_decimal_lat_long; Type: VIEW; Schema: public_validations; Owner: -
8315
--
8316

  
8317
CREATE VIEW _specimens_13_count_of_all_verbatim_and_decimal_lat_long AS
8318
 SELECT ( SELECT count(*) AS count
8319
           FROM public.coordinates
8320
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND ((coordinates.verbatimlatitude IS NOT NULL) OR (coordinates.latitude_deg IS NOT NULL)))) AS "allLats", 
8321
    ( SELECT count(*) AS count
8322
           FROM public.coordinates
8323
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (coordinates.latitude_deg IS NOT NULL))) AS "decimalLats", 
8324
    ( SELECT count(*) AS count
8325
           FROM public.coordinates
8326
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND ((coordinates.verbatimlongitude IS NOT NULL) OR (coordinates.longitude_deg IS NOT NULL)))) AS "allLongs", 
8327
    ( SELECT count(*) AS count
8328
           FROM public.coordinates
8329
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (coordinates.longitude_deg IS NOT NULL))) AS "decimalLongs";
8330

  
8331

  
8332
--
8333
-- Name: _specimens_14_count_of_all_invalid_verbatim_lat_long; Type: VIEW; Schema: public_validations; Owner: -
8334
--
8335

  
8336
CREATE VIEW _specimens_14_count_of_all_invalid_verbatim_lat_long AS
8337
 SELECT ( SELECT count(*) AS count
8338
           FROM public.coordinates
8339
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND ((coordinates.latitude_deg > (90)::double precision) OR (coordinates.latitude_deg < ((-90))::double precision)))) AS "badLats", 
8340
    ( SELECT count(*) AS count
8341
           FROM public.coordinates
8342
          WHERE ((coordinates.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND ((coordinates.longitude_deg > (180)::double precision) OR (coordinates.longitude_deg < ((-180))::double precision)))) AS "badLongs";
8343

  
8344

  
8345
--
8346
-- Name: _specimens_15_list_distinct_locality_descriptions; Type: VIEW; Schema: public_validations; Owner: -
8347
--
8348

  
8349
CREATE VIEW _specimens_15_list_distinct_locality_descriptions AS
8350
 SELECT DISTINCT location.locationnarrative AS "localityDescription"
8351
   FROM public.location
8352
  WHERE ((location.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (location.locationnarrative IS NOT NULL));
8353

  
8354

  
8355
--
8356
-- Name: _specimens_16_list_distinct_specimen_descriptions; Type: VIEW; Schema: public_validations; Owner: -
8357
--
8358

  
8359
CREATE VIEW _specimens_16_list_distinct_specimen_descriptions AS
8360
 SELECT DISTINCT aggregateoccurrence.notes AS "specimenDescription"
8361
   FROM public.aggregateoccurrence
8362
  WHERE ((aggregateoccurrence.source_id = ( SELECT public.source_by_shortname(("current_schema"())::text) AS source_by_shortname)) AND (aggregateoccurrence.notes IS NOT NULL));
8363

  
8364

  
8365
--
8175 8366
-- Name: _traits_01_count_records; Type: VIEW; Schema: public_validations; Owner: -
8176 8367
--
8177 8368

  

Also available in: Unified diff