n.b. to connect to the database used in the examples below you should clone the example repository

Database Queries

Style

seLEcT FDate, TEMP, weather, wiNd FrOm coLLection_EVENt wheRe temP > 30 aND site = 'DM';

Selecting columns

SELECT siteID, treatment, soil
FROM sites;
SELECT treatment, soil, siteID
FROM sites;
SELECT *
FROM specimens;
SELECT DISTINCT Family, Genus 
FROM bee_traits;

SELECT siteID, latitude/100
FROM sites;
SELECT siteID, ROUND(latitude, 2)
FROM sites;

Filtering

SELECT Family, Genus 
FROM bee_traits 
WHERE family = "Apidae" or family = "Andrenidae";
SELECT siteID
FROM sites
WHERE latitude >= 45;
SELECT fdate, weather, temp, wind
FROM collection_events
WHERE site = 'HI' AND temp > 25;
SELECT genus, species, subspecies
FROM bee_traits
WHERE subspecies IS NOT NULL;