Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created December 23, 2018 15:37
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 Kcko/60584b847e643ea4e8a451437525a1a0 to your computer and use it in GitHub Desktop.
Save Kcko/60584b847e643ea4e8a451437525a1a0 to your computer and use it in GitHub Desktop.
select * from clanky where (kategorie, datum) in (select kategorie, max(datum) from clanky group by kategorie)
SELECT
t1.id,
t1.nadpis,
t2.datum,
t1.datum,
t2.kategorie
FROM clanky t1
JOIN ( SELECT t2.kategorie, MAX(t2.datum) datum FROM clanky t2 GROUP BY t2.kategorie) t2
ON t1.kategorie = t2.kategorie
AND t1.datum = t2.datum
select * from clanky t1
where t1.id in (select max(t2.id) id from clanky t2 group by t2.kategorie)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment