Pages

Tuesday, August 7, 2012

ORDER BY Column not in GROUP BY


Consider the following data given in the below table

Table Name: mytable


Problem: group by the table data by column1 and column2 but final out put should be ordered by column3

Answer:
SELECT column1, column2
    FROM mytbl
GROUP BY column1, column2
ORDER BY MAX (column3)

No comments:

Post a Comment