Created
May 21, 2012 16:44
Revisions
-
robheittman revised this gist
May 21, 2012 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,12 @@ CREATE TABLE st_countryoccurrence AS LEFT JOIN lookups."COUNTRYOCCURRENCE_PRESENCELOOKUP" pres ON pres."ID" = c_pres.value LEFT JOIN st_countryoccurrencesubfield_origin c_origin ON country.recordid = c_origin.recordid LEFT JOIN lookups."COUNTRYOCCURRENCE_ORIGINLOOKUP" origin ON origin."ID" = c_origin.value; drop table if exists st_infrarank; create table st_infrarank as select * from vw_published.vw_infrarank; drop table if exists st_species; create table st_species as select * from vw_published.vw_species; drop table if exists st_redlistcategoryandcriteria_all; create table st_redlistcategoryandcriteria_all as select * from vw_published.vw_redlistcategoryandcriteria; drop table if exists st_all_taxa; create table st_all_taxa as select * from st_infrarank union select *, '', '' from st_species; drop table if exists st_all_taxa_criteria; @@ -31,4 +37,4 @@ create table st_all_taxa_criteria_regions_ws as select g.*, name ws from st_all_ drop table if exists published_2012_1; create table published_2012_1 as select ws, count(*) from st_all_taxa_criteria_global_ws where ws ilike 'PUBLISHED_2012.1%' group by ws order by ws; drop table if exists multi_regional_2012_1; create table multi_regional_2012_1 as select distinct taxonid, genus, species, infratype, assessmentid, region from st_all_taxa_criteria_regions where taxonid in (select taxonid from (select taxonid, genus, species, assessmentid, count(assessmentid) from st_all_taxa_criteria_ws where ws ilike 'PUBLISHED_2012.1%' group by taxonid, genus, species, assessmentid having count(assessmentid)>1 order by assessmentid) s1) and region!=1 order by taxonid, assessmentid; -
robheittman revised this gist
May 21, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,6 +25,9 @@ drop table if exists st_all_taxa_criteria_global; create table st_all_taxa_criteria_global as select * from st_all_taxa_criteria_by_region where region=1; drop table if exists st_all_taxa_criteria_global_ws; create table st_all_taxa_criteria_global_ws as select g.*, name ws from st_all_taxa_criteria_global g left join vw_published.vw_workingsettaxon w on g.taxonid=w.taxonid; drop table if exists st_all_taxa_criteria_regions_ws; create table st_all_taxa_criteria_regions_ws as select g.*, name ws from st_all_taxa_criteria_by_region g left join vw_published.vw_workingsettaxon w on g.taxonid=w.taxonid; drop table if exists published_2012_1; create table published_2012_1 as select ws, count(*) from st_all_taxa_criteria_global_ws where ws ilike 'PUBLISHED_2012.1%' group by ws order by ws; drop table if exists multi_regional_2012_1; -
robheittman revised this gist
May 21, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,3 +27,5 @@ drop table if exists st_all_taxa_criteria_global_ws; create table st_all_taxa_criteria_global_ws as select g.*, name ws from st_all_taxa_criteria_global g left join vw_published.vw_workingsettaxon w on g.taxonid=w.taxonid; drop table if exists published_2012_1; create table published_2012_1 as select ws, count(*) from st_all_taxa_criteria_global_ws where ws ilike 'PUBLISHED_2012.1%' group by ws order by ws; drop table if exists multi_regional_2012_1; create table multi_regional_2012_1 as select distinct taxonid, genus, species, infratype, assessmentid, region from st_all_taxa_criteria_ws where taxonid in (select taxonid from (select taxonid, genus, species, assessmentid, count(assessmentid) from st_all_taxa_criteria_ws where ws ilike 'PUBLISHED_2012.1%' group by taxonid, genus, species, assessmentid having count(assessmentid)>1 order by assessmentid) s1) and region!=1 order by taxonid, assessmentid; -
robheittman revised this gist
May 21, 2012 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,3 +15,15 @@ CREATE TABLE st_countryoccurrence AS LEFT JOIN lookups."COUNTRYOCCURRENCE_PRESENCELOOKUP" pres ON pres."ID" = c_pres.value LEFT JOIN st_countryoccurrencesubfield_origin c_origin ON country.recordid = c_origin.recordid LEFT JOIN lookups."COUNTRYOCCURRENCE_ORIGINLOOKUP" origin ON origin."ID" = c_origin.value; drop table if exists st_all_taxa; create table st_all_taxa as select * from st_infrarank union select *, '', '' from st_species; drop table if exists st_all_taxa_criteria; create table st_all_taxa_criteria as select t.*, c.assessmentid, c.rlcategory, c.rlcriteria, c.critversion, c.ismanual from st_all_taxa t, st_redlistcategoryandcriteria_all c where t.taxonid = c.taxonid; drop table if exists st_all_taxa_criteria_by_region; create table st_all_taxa_criteria_by_region as select a.*, r.value region from st_all_taxa_criteria a join vw_published.vw_regioninformation_regions r on a.assessmentid = r.assessmentid; drop table if exists st_all_taxa_criteria_global; create table st_all_taxa_criteria_global as select * from st_all_taxa_criteria_by_region where region=1; drop table if exists st_all_taxa_criteria_global_ws; create table st_all_taxa_criteria_global_ws as select g.*, name ws from st_all_taxa_criteria_global g left join vw_published.vw_workingsettaxon w on g.taxonid=w.taxonid; drop table if exists published_2012_1; create table published_2012_1 as select ws, count(*) from st_all_taxa_criteria_global_ws where ws ilike 'PUBLISHED_2012.1%' group by ws order by ws; -
robheittman revised this gist
May 21, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ vacuum analyze; drop table if exists st_countryoccurrencesubfield_countryoccurrencelookup; create table st_countryoccurrencesubfield_countryoccurrencelookup as select * from vw_published.vw_countryoccurrencesubfield_countryoccurrencelookup ; drop table if exists st_countryoccurrencesubfield_presence; -
robheittman revised this gist
May 21, 2012 . 1 changed file with 10 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,16 @@ drop table if exists st_countryoccurrencesubfield_countryoccurrencelookup; create table st_countryoccurrencesubfield_countryoccurrencelookup as select * from vw_published.vw_countryoccurrencesubfield_countryoccurrencelookup ; drop table if exists st_countryoccurrencesubfield_presence; create table st_countryoccurrencesubfield_presence as select * from vw_published.vw_countryoccurrencesubfield_presence; drop table if exists st_countryoccurrencesubfield_origin; create table st_countryoccurrencesubfield_origin as select * from vw_published.vw_countryoccurrencesubfield_origin; DROP TABLE IF EXISTS st_countryoccurrence; CREATE TABLE st_countryoccurrence AS SELECT country.taxonid, country.assessmentid, country.value, country.recordid, record."CODE" as code, record."DESCRIPTION" as country, pres."LABEL" as presence, origin."LABEL" as origin FROM st_countryoccurrencesubfield_countryoccurrencelookup country JOIN lookups."COUNTRYOCCURRENCELOOKUP" record ON record."ID" = country.value LEFT JOIN st_countryoccurrencesubfield_presence c_pres ON country.recordid = c_pres.recordid LEFT JOIN lookups."COUNTRYOCCURRENCE_PRESENCELOOKUP" pres ON pres."ID" = c_pres.value LEFT JOIN st_countryoccurrencesubfield_origin c_origin ON country.recordid = c_origin.recordid LEFT JOIN lookups."COUNTRYOCCURRENCE_ORIGINLOOKUP" origin ON origin."ID" = c_origin.value; -
robheittman created this gist
May 21, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ DROP TABLE IF EXISTS st_countryoccurrence; CREATE TABLE st_countryoccurrence AS SELECT country.taxonid, country.assessmentid, country.value, country.recordid, record."CODE" as code, record."DESCRIPTION" as country, pres."LABEL" as presence, origin."LABEL" as origin FROM vw_published.vw_countryoccurrencesubfield_countryoccurrencelookup country JOIN lookups."COUNTRYOCCURRENCELOOKUP" record ON record."ID" = country.value LEFT JOIN vw_published.vw_countryoccurrencesubfield_presence c_pres ON country.recordid = c_pres.recordid LEFT JOIN lookups."COUNTRYOCCURRENCE_PRESENCELOOKUP" pres ON pres."ID" = c_pres.value LEFT JOIN vw_published.vw_countryoccurrencesubfield_origin c_origin ON country.recordid = c_origin.recordid LEFT JOIN lookups."COUNTRYOCCURRENCE_ORIGINLOOKUP" origin ON origin."ID" = c_origin.value