Skip to content

Instantly share code, notes, and snippets.

@iyank4
Created July 17, 2014 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iyank4/d4206d9c930e85c8d55e to your computer and use it in GitHub Desktop.
Save iyank4/d4206d9c930e85c8d55e to your computer and use it in GitHub Desktop.
Simple SQL Select with Group and Order By Specific Column
SELECT * FROM
(
SELECT * the_table
ORDER BY created_at_field DESC
) t
GROUP BY t.id_field
-- On MySQL with InnoDB engine this query was returning the expected result, but i have no idea with another database and engine.
-- Hopefully this trick would work, tell me if it's not. And maybe you can use more complex query as explined on stackoverflow or others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment