Skip to content

Instantly share code, notes, and snippets.

@jimmybaker
Created November 24, 2009 16:12
Show Gist options
  • Save jimmybaker/241975 to your computer and use it in GitHub Desktop.
Save jimmybaker/241975 to your computer and use it in GitHub Desktop.
select u.id, u.first_name, u.last_name, u.email,
(select so.shipto_postal_code from sales_orders so where so.user_id = u.id and so.state != 'pending' order by so.placed_at desc limit 1)
from users u
where
u.contact_me = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment