Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
Sexual Content
Violent or Repulsive Content
Hateful or Abusive Content
Harmful Dangerous Acts
Child Abuse
Spam
Infringes My Rights
Here is the issue and the solution which i have faced during a sql query where i want result like :
>> Consider the table name as stat and column name as month and year
>> First i have tried with the qurey : "select month,year from stat group by month, year order by month,year desc;"
mysql> select month,year from stat group by month, year order by month,year desc;
+-------+------+
| month | year |
+-------+------+
| 1 | 2010 |
| 7 | 2009 |
| 8 | 2009 |
| 9 | 2009 |
| 10 | 2009 |
| 11 | 2009 |
| 12 | 2009 |
+-------+------+
>> Next i have tried the right query : "select month,year from stat group by month order by year desc,month desc;";
mysql> select month,year from stat group by month order by year desc,month desc;
+-------+------+
| month | year |
+-------+------+
| 1 | 2010 |
| 12 | 2009 |
| 11 | 2009 |
| 10 | 2009 |
| 9 | 2009 |
| 8 | 2009 |
| 7 | 2009 |
+-------+------+
now i have got the desired result so if you want to order the result by consider two columns then try with qurey which is similar to "select month,year from stat group by month order by year desc,month desc;";