Skip to content

Commit aa4768d

Browse files
author
jamesquinlan
committed
init
1 parent ab4b7a6 commit aa4768d

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

sql/joins1.sql

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2+
-- Description: How many flights on Christmas to Chicago
3+
-- (ORD) from LGA?
4+
--
5+
-- Course: Intro. to Database
6+
-- Author: Quinlan, J.
7+
-- Date: 2023-04-13
8+
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+
10+
use nycFlights;
11+
12+
SELECT
13+
distinct P.tailnum, CONCAT(P.manufacturer, ' ', P.model) AS Plane, P.seats, F.dest
14+
FROM
15+
Planes AS P
16+
INNER JOIN
17+
Flights AS F ON P.tailnum = F.tailnum where origin = 'JFK';
18+
19+
20+
21+
-- =================================
22+
SELECT
23+
distinct P.tailnum, CONCAT(P.manufacturer, ' ', P.model) AS Plane, P.seats
24+
FROM
25+
Planes AS P
26+
INNER JOIN
27+
Flights AS F ON P.tailnum = F.tailnum where origin = 'JFK' and dest = 'ATL';
28+
29+
30+
-- ===================================
31+
32+
SELECT
33+
COUNT(seats) AS Flights,
34+
ROUND(AVG(seats), 0) AS Seats,
35+
COUNT(seats) * ROUND(AVG(seats), 0) as Volume
36+
FROM
37+
(SELECT DISTINCT
38+
P.tailnum, P.seats
39+
FROM
40+
Planes AS P
41+
INNER JOIN Flights AS F ON P.tailnum = F.tailnum
42+
WHERE
43+
origin = 'JFK' AND dest = 'ATL') AS X;

sql/joins2.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2+
-- Description: How many flights on Christmas to Chicago
3+
-- (ORD) from LGA?
4+
--
5+
-- Course: Intro. to Database
6+
-- Author: Quinlan, J.
7+
-- Date: 2023-04-13
8+
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+
10+
use nycFlights;
11+
SELECT
12+
visib, wind_speed, wind_gust
13+
FROM
14+
Flights AS F
15+
INNER JOIN
16+
Weather AS W ON F.origin = W.origin
17+
WHERE
18+
F.dep_delay > 60 AND F.origin = 'JFK';

0 commit comments

Comments
 (0)