Skip to content

Instantly share code, notes, and snippets.

@shofetim
Created June 23, 2015 22:16
Show Gist options
  • Save shofetim/cd62f6cbb00cef36075f to your computer and use it in GitHub Desktop.
Save shofetim/cd62f6cbb00cef36075f to your computer and use it in GitHub Desktop.
SELECT
req.is_archived,
req.contact_name AS Name,
req.address_1 AS "Address 1",
req.address_2 AS "Address 2",
req.city AS City,
states.abbrev AS State,
states.name AS "State Name",
req.postal_code AS Zip,
req.email AS Email,
to_char(req.created_at, 'DD Mon YYYY') AS "Request Date"
FROM webforms_catalogrequest AS req
--INNER JOIN customers_customer AS c ON c.alternative_email_1 = req.email --OR c.alternative_email_2 = req.email
INNER JOIN countries_usstate AS states ON states.id=req.state_id
WHERE req.created_at > CURRENT_DATE - INTERVAL '90 day'
ORDER BY states.abbrev;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment