I have a temporary table #temp that has following records:
col1 col2
a 11
a 12
a 13
b 5
b 8
I want to only keep records that have max col2, the result table should be like
col1 col2
a 13
b 8
can anybody help me to write the query without creating another temp table?
Demo on SQLFiddle