Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 11, 2020 07:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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