Class activity solutions

Author

Ciaran Evans

library(tidyverse)
library(mdsr)
library(DBI)
db <- dbConnect_scidb("airlines")
query <- "
SELECT tailnum, year FROM planes LIMIT 0,5;
"
dbGetQuery(db, query)
  tailnum year
1  N10156 2004
2  N102UW 1998
3  N103US 1999
4  N104UW 1999
5  N10575 2002
query <- "
SELECT MIN(year) FROM planes LIMIT 0,5;
"
dbGetQuery(db, query)
  MIN(year)
1      1956
query <- "
SELECT tailnum, year FROM planes WHERE year = 1956 LIMIT 0,5;
"
dbGetQuery(db, query)
  tailnum year
1  N381AA 1956
query <- "
SELECT year, SUM(1) AS N 
FROM planes 
WHERE year = (SELECT MAX(year) FROM planes)
LIMIT 0,10;
"
dbGetQuery(db, query)
  year  N
1 2013 92