Skip to content

Instantly share code, notes, and snippets.

@gamov
Created November 18, 2010 09:51
Show Gist options
  • Save gamov/704819 to your computer and use it in GitHub Desktop.
Save gamov/704819 to your computer and use it in GitHub Desktop.
## greatest n per group
SELECT * FROM shipping_items As t1
WHERE t1.created_at = (SELECT Max(created_at)
FROM shipping_items As t2
WHERE t2.item_variant_id = t1.item_variant_id
AND t2.item_variant_id in (11,10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment