Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 11, 2020 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/61d5cc6ca34ecd98b9b2befde75f1b58 to your computer and use it in GitHub Desktop.
Save velotiotech/61d5cc6ca34ecd98b9b2befde75f1b58 to your computer and use it in GitHub Desktop.
Give FirstNames of People from Minnesota with amount_due more than $100
WITH basic AS
(SELECT id,
first_name
FROM basic_details
WHERE lower(gender) = 'male' ), bill AS
(SELECT id
FROM bil_details
WHERE CAST(amount_due AS INTEGER) > 100 ), contact AS
(SELECT contact_details.id
FROM contact_details
JOIN bill
ON contact_details.id = bill.id
WHERE state= 'Minnesota' )
SELECT basic.first_name
FROM basic
JOIN contact
ON basic.id = contact.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment