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
-- CODE CHALLENGE 1 | |
-- Select the title, author, and average_rating of each book with an average_rating between 3.5 and 4.5. | |
SELECT | |
title, | |
author, | |
average_rating | |
FROM books | |
WHERE average_rating BETWEEN 3.5 AND 4.5; | |
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
-- Let’s see what our table contains | |
SELECT * | |
FROM state_climate | |
WHERE state = 'Alabama' | |
LIMIT 5; | |
-- How the average temperature changes over time in each state. | |
SELECT |
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
/* | |
Here's the first-touch query, in case you need it | |
*/ | |
WITH first_touch AS ( | |
SELECT user_id, | |
MIN(timestamp) as first_touch_at | |
FROM page_visits | |
GROUP BY user_id), | |
ft_attr AS | |
( |
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
SELECT * | |
FROM orders | |
LIMIT 10; | |
SELECT DISTINCT order_date | |
FROM orders; | |
SELECT special_instructions | |
FROM orders | |
LIMIT 20; |
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
SELECT * | |
FROM users | |
LIMIT 20; | |
SELECT email, birthday | |
FROM users | |
WHERE birthday BETWEEN '1980-01-01' AND '1989-12-31'; | |
SELECT email, created_at | |
FROM users |
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
SELECT * | |
FROM transaction_data | |
LIMIT 10; | |
SELECT full_name, email, zip | |
FROM transaction_data | |
WHERE zip = 20252; | |
SELECT full_name, email | |
FROM transaction_data |
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
SELECT * | |
FROM nomnom; | |
SELECT DISTINCT neighborhood | |
FROM nomnom; | |
SELECT DISTINCT cuisine | |
FROM nomnom; | |
SELECT * |
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
CREATE TABLE friends ( | |
id INTEGER, | |
name TEXT, | |
birthday DATE | |
); | |
INSERT INTO friends | |
VALUES (1, 'Jane Doe', 1990-05-30); | |
SELECT * |
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
WITH | |
MONTHS AS | |
( | |
SELECT | |
'2017-01-01' AS FIRST_DATE, | |
'2017-01-31' AS LAST_DATE | |
UNION | |
SELECT | |
'2017-02-01' AS FIRST_DATE, | |
'2017-02-29' AS LAST_dATE |