Skip to content

Instantly share code, notes, and snippets.

@geelen
Created October 2, 2013 02:47
Show Gist options
  • Select an option

  • Save geelen/6788430 to your computer and use it in GitHub Desktop.

Select an option

Save geelen/6788430 to your computer and use it in GitHub Desktop.
SELECT submissions.*
FROM submission
INNER JOIN
(
SELECT submission_id, max(id) as max_id
FROM statuses
GROUP BY submission_id
) sub_query
ON submissions.id = sub_query.submission_id
INNER JOIN statuses
ON statuses.id = sub_query.max_id
AND statuses.status LIKE 'robots'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment