I want to write a query such that I get a single row for duplicate records in col1, col2, and col3 and max value of Id. For example 12 Ajay val1 val2 val3 15 Malik val4 val5 val6 17 Mehul val7 val8 val9
Can anybody help me on this? Thank you in advance.
You almost literally gave the answer in your question. You do this by selecting the values you want to get, using max(id) to get max value of id, and group by all fields you selected, except max(id).