Skip to content

Instantly share code, notes, and snippets.

@drobison
Created February 22, 2014 02:31
Show Gist options
  • Select an option

  • Save drobison/9147755 to your computer and use it in GitHub Desktop.

Select an option

Save drobison/9147755 to your computer and use it in GitHub Desktop.

Revisions

  1. drobison created this gist Feb 22, 2014.
    10 changes: 10 additions & 0 deletions gistfile1.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    SELECT p.id
    FROM Posts as p
    JOIN (
    SELECT id
    , MAX(date_modified) as ModifiedDate
    FROM Posts
    GROUP BY user_id
    ) lastPost ON p.id = lastPost.id
    AND p.date_modified = lastPost.ModifiedDate
    order by p.user_id