Project

General

Profile

« Previous | Next » 

Revision 12647

schemas/vegbien.sql: implemented _plots_16_intercepts_for_each_verb_taxon_in_each_plot_each_proj

View differences:

vegbien.sql
625 625

  
626 626

  
627 627
--
628
-- Name: keys_~type._plots_16_intercepts_for_each_verb_taxon_in_each_plo; Type: TYPE; Schema: public_validations; Owner: -
629
--
630

  
631
CREATE TYPE "keys_~type._plots_16_intercepts_for_each_verb_taxon_in_each_plo" AS (
632
	project_name text,
633
	plot_code text,
634
	taxon text
635
);
636

  
637

  
638
--
628 639
-- Name: keys_~type._plots_17_count_of_subplots_per_plot_for_each_projec; Type: TYPE; Schema: public_validations; Owner: -
629 640
--
630 641

  
......
899 910

  
900 911

  
901 912
--
913
-- Name: values__~type._plots_16_intercepts_for_each_verb_taxon_in_each_; Type: TYPE; Schema: public_validations; Owner: -
914
--
915

  
916
CREATE TYPE "values__~type._plots_16_intercepts_for_each_verb_taxon_in_each_" AS (
917
	intercept_cm double precision
918
);
919

  
920

  
921
--
902 922
-- Name: values__~type._plots_17_count_of_subplots_per_plot_for_each_pro; Type: TYPE; Schema: public_validations; Owner: -
903 923
--
904 924

  
......
2895 2915

  
2896 2916

  
2897 2917
--
2918
-- Name: ~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac; Type: TABLE; Schema: public_validations; Owner: -; Tablespace: 
2919
--
2920

  
2921
CREATE TABLE "~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac" (
2922
    project_name text,
2923
    plot_code text,
2924
    taxon text,
2925
    intercept_cm double precision
2926
);
2927

  
2928

  
2929
--
2930
-- Name: keys("~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac"); Type: FUNCTION; Schema: public_validations; Owner: -
2931
--
2932

  
2933
CREATE FUNCTION keys(value "~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac") RETURNS "keys_~type._plots_16_intercepts_for_each_verb_taxon_in_each_plo"
2934
    LANGUAGE sql IMMUTABLE
2935
    AS $_$
2936
SELECT ROW($1.project_name, $1.plot_code, $1.taxon)::public_validations."keys_~type._plots_16_intercepts_for_each_verb_taxon_in_each_plo"
2937
$_$;
2938

  
2939

  
2940
--
2898 2941
-- Name: ~type._plots_17_count_of_subplots_per_plot_for_each_project; Type: TABLE; Schema: public_validations; Owner: -; Tablespace: 
2899 2942
--
2900 2943

  
......
3777 3820

  
3778 3821

  
3779 3822
--
3823
-- Name: values_("~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac"); Type: FUNCTION; Schema: public_validations; Owner: -
3824
--
3825

  
3826
CREATE FUNCTION values_(value "~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac") RETURNS "values__~type._plots_16_intercepts_for_each_verb_taxon_in_each_"
3827
    LANGUAGE sql IMMUTABLE
3828
    AS $_$
3829
SELECT ROW($1.intercept_cm)::public_validations."values__~type._plots_16_intercepts_for_each_verb_taxon_in_each_"
3830
$_$;
3831

  
3832

  
3833
--
3780 3834
-- Name: values_("~type._plots_17_count_of_subplots_per_plot_for_each_project"); Type: FUNCTION; Schema: public_validations; Owner: -
3781 3835
--
3782 3836

  
......
7862 7916

  
7863 7917

  
7864 7918
--
7919
-- Name: _plots_16_intercepts_for_each_verb_taxon_in_each_plot_each_proj; Type: VIEW; Schema: public_validations; Owner: -
7920
--
7921

  
7922
CREATE VIEW _plots_16_intercepts_for_each_verb_taxon_in_each_plot_each_proj AS
7923
 SELECT DISTINCT p.projectname AS project_name, 
7924
    l.authorlocationcode AS plot_code, 
7925
    btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text))) AS taxon, 
7926
    sum(ao.linecover_m) AS intercept_cm
7927
   FROM ((((((((public.project p
7928
   JOIN public.source s ON ((p.source_id = s.source_id)))
7929
   JOIN public.locationevent le ON ((p.project_id = le.project_id)))
7930
   JOIN public.locationevent sub_locationevent ON ((sub_locationevent.parent_id = le.locationevent_id)))
7931
   JOIN public.plot l ON ((le.location_id = l.plot_id)))
7932
   JOIN public.taxonoccurrence o ON ((sub_locationevent.locationevent_id = o.locationevent_id)))
7933
   JOIN public.taxondetermination td ON ((td.taxonoccurrence_id = o.taxonoccurrence_id)))
7934
   JOIN public.taxonverbatim tv ON ((td.taxonverbatim_id = tv.taxonverbatim_id)))
7935
   JOIN public.aggregateoccurrence ao ON ((o.taxonoccurrence_id = ao.taxonoccurrence_id)))
7936
  WHERE (((s.shortname = ("current_schema"())::text) AND (td.isoriginal = true)) AND (ao.linecover_m IS NOT NULL))
7937
  GROUP BY p.projectname, l.authorlocationcode, btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text)))
7938
  ORDER BY p.projectname, l.authorlocationcode, btrim((((((((''::text || COALESCE(tv.family, ''::text)) || ' '::text) || COALESCE(tv.genus, ''::text)) || ' '::text) || COALESCE(tv.specific_epithet, ''::text)) || ' '::text) || COALESCE(tv.morphospecies, ''::text)));
7939

  
7940

  
7941
--
7942
-- Name: VIEW _plots_16_intercepts_for_each_verb_taxon_in_each_plot_each_proj; Type: COMMENT; Schema: public_validations; Owner: -
7943
--
7944

  
7945
COMMENT ON VIEW _plots_16_intercepts_for_each_verb_taxon_in_each_plot_each_proj IS '
7946
Note 1: Assumes identical concatenation of taxonomic fields to form verbatim taxon name in origina db
7947
Note 2: Grouping mean cover for entire plot combines plots with subplots (separate cover measure for each species in each subplot) with  plots with strata (separate cover measures for each species in each  stratum) with plots without subplots or strata (one cover measure  per species per plot.
7948
';
7949

  
7950

  
7951
--
7865 7952
-- Name: _plots_17_count_of_subplots_per_plot_for_each_project; Type: VIEW; Schema: public_validations; Owner: -
7866 7953
--
7867 7954

  
......
10930 11017

  
10931 11018

  
10932 11019
--
11020
-- Data for Name: ~type._plots_16_intercepts_for_each_verb_taxon_in_each_plot_eac; Type: TABLE DATA; Schema: public_validations; Owner: -
11021
--
11022

  
11023

  
11024

  
11025
--
10933 11026
-- Data for Name: ~type._plots_17_count_of_subplots_per_plot_for_each_project; Type: TABLE DATA; Schema: public_validations; Owner: -
10934 11027
--
10935 11028

  

Also available in: Unified diff