我有下一个mysql表结构:
++++++++++++++++++++++++++++++++++++
+ id + value + month + year + type +
++++++++++++++++++++++++++++++++++++
我想做下一个选择:
SELECT
*
FROM
Table
但是ORDER BY
选项。我想在YEAR-MONTH复合字段DESC上对结果进行排序。
我需要这样的东西:
SELECT
*
FROM
Table
ORDER BY
YEAR-MONTH
DESC
我怎么能这样做?
答案 0 :(得分:5)
SELECT
*
FROM
Table
ORDER BY
YEAR DESC,
MONTH DESC
答案 1 :(得分:0)
SELECT CONCAT( year, month ) AS _sorter, *
FROM table
ORDER BY _sorter