Accessing Data
What query would you write to access every entry in the Users dataset?
Sorting and Limiting Results
How would you write a query to pull only the Top 3 payment amounts from the Payments dataset?
Filtering Data
What query would you write to pull all payment data in 2018, or any payment that's been returned from the Payments dataset?
Segmentation
How would you write a query to create a new field that segments users into either a paid or organic registration?
Joining Multiple Datasets Together
What query would you write to join the Users and Payments datasets together, and identify the paid users that signed up on, or after June 1, 2018?
Accessing Data
What query would you write to access every entry in the Users dataset?
SELECT *
FROM getting_started.users
;
Sorting and Limiting Results
How would you write a query to pull only the Top 3 payment amounts from the Payments dataset?
SELECT payment_amount
FROM getting_started.payments
ORDER BY payment_amount
LIMIT 3 DESC
;
Filtering Data
What query would you write to pull all payment data in 2018, or any payment that's been returned from the Payments dataset?
SELECT *
FROM getting_started.payments
WHERE
payment_timestamp BETWEEN '2018-01-01' AND '2018-12-31'
OR
payment_returned = TRUE
;
Segmentation
How would you write a query to create a new field that segments users into either a paid or organic registration?
SELECT
*
, CASE WHEN acquisition_source = 'Social Media' THEN 'Paid'
ELSE 'Organic' END AS acquisition_type
FROM getting_started.users
;
Joining Multiple Datasets Together
What query would you write to join the Users and Payments datasets together, and identify the paid users that signed up on, or after June 1, 2018?
SELECT *
FROM getting_started.users
INNER JOIN getting_started.payments ON users.user_id = payments.user_id
WHERE users.signup_timestamp >= '2018-06-01'
;