I\'m hoping there\'s a simple way to do this without using a sub-query:
Scenario: You have \"TableA\" with columns \"Key\", \"SubKey\", and \"Value\". I need to ge
In case of multiple keys using a CTE:
WITH CTE AS ( SELECT key1, key2, MAX(subkey) AS MaxSubkey FROM TableA GROUP BY key1, key2 ) SELECT a.Key1, a.Key2, a.Value FROM TableA a INNER JOIN CTE ON a.key1 = CTE.key1 AND a.key2 = CTE.key2 AND a.subkey = CTE.MaxSubkey