Skip to content

Instantly share code, notes, and snippets.

@robheittman
Created May 21, 2012 16:44
Show Gist options
  • Save robheittman/2763207 to your computer and use it in GitHub Desktop.
Save robheittman/2763207 to your computer and use it in GitHub Desktop.
Static tables for Red List publish
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment