Guest User

Untitled

a guest
Jul 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. select * from generic_shop
  2. where (type, timestamp) in (
  3. select type, max(timestamp)
  4. from generic_shop
  5. group by type
  6. ) order by type
  7.  
  8. SELECT g1.*
  9. FROM generic_shop g1
  10. INNER JOIN
  11. (
  12. SELECT type, MAX(timestamp) AS max_timestamp
  13. FROM generic_shop
  14. GROUP BY type
  15. ) g2
  16. ON g1.type = g2.type AND g1.timestamp = g2.max_timestamp;
  17. ORDER BY
  18. g1.type;
Add Comment
Please, Sign In to add comment