Created
April 15, 2013 19:12
-
-
Save dlebauer/5390548 to your computer and use it in GitHub Desktop.
Queries for yieldsview and traitsview from BETYdb
This file contains 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 characters
drop view if exists yieldsview; | |
create view yieldsview as select yields.id as yield_id, yields.citation_id, yields.site_id, yields.treatment_id, sites.sitename as site, sites.city, sites.lat, sites.lon, species.scientificname, species.genus, citations.author as author, citations.year as cityear, treatments.name as trt, date, month(date) as month, year(date) as year, mean, n, statname, stat, yields.notes, users.name as user, planting, seeding from yields left join sites on yields.site_id = sites.id left join species on yields.specie_id = species.id left join citations on yields.citation_id = citations.id left join treatments on yields.treatment_id = treatments.id left join users on yields.user_id = users.id left join mgmtview on yields.id = mgmtview.yield_id; | |
drop view if exists traitsview; | |
create view traitsview as select traits.id as trait_id, traits.citation_id, traits.site_id, traits.treatment_id, sites.sitename as site, sites.city, sites.lat, sites.lon, species.scientificname, species.genus, citations.author as author, citations.year as cityear, treatments.name as trt, date, month(date) as month, year(date) as year, variables.name as trait, mean, n, statname, stat, traits.notes, users.name as user from traits join sites on traits.site_id = sites.id join species on traits.specie_id = species.id join citations on traits.citation_id = citations.id join treatments on traits.treatment_id = treatments.id join variables on traits.variable_id = variables.id join users on traits.user_id = users.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment