-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d38cd1e
commit 671458f
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CREATE TABLE pizzas AS | ||
SELECT "Artichoke" AS name, 12 AS open, 15 AS close UNION | ||
SELECT "La Val's" , 11 , 22 UNION | ||
SELECT "Sliver" , 11 , 20 UNION | ||
SELECT "Cheeseboard" , 16 , 23 UNION | ||
SELECT "Emilia's" , 13 , 18; | ||
|
||
CREATE TABLE meals AS | ||
SELECT "breakfast" AS meal, 11 AS time UNION | ||
SELECT "lunch" , 13 UNION | ||
SELECT "dinner" , 19 UNION | ||
SELECT "snack" , 22; | ||
|
||
-- Q1: Open Early | ||
select name from pizzas where open < 13 order by name; | ||
|
||
-- Q2: Study Session | ||
create table study as select name as name, max(14 - open, 0) as duration | ||
from pizzas order by duration DESC; | ||
|
||
-- Q3: Late Night Snack | ||
create table snack as select pizzas.name || " closes at " || pizzas.close as status | ||
from pizzas, meals where meals.meal = "snack" and pizzas.close >= meals.time; | ||
|
||
-- Q4: Double Pizza | ||
-- Two meals at the same place | ||
CREATE TABLE double AS | ||
SELECT a.meal AS first, b.meal AS second, name | ||
FROM meals AS a, meals AS b, pizzas | ||
WHERE b.time - a.time > 6 | ||
AND pizzas.open <= a.time | ||
AND pizzas.close >= b.time; |