日期:2014-05-16  浏览次数:20719 次

请看我的sql 最后用orderby排序居然无效 求解 急!!!
SELECT 
  * 
FROM
  (SELECT 
  INSTITUTIONID,
  SYMBOL,
  MAX(IF(ENDDATE = '2011-09-30', `EPS`, 0)) AS '2011三季报',
  MAX(IF(ENDDATE = '2011-12-31', `EPS`, 0)) AS '2011年报',
  MAX(IF(ENDDATE = '2012-03-31', `EPS`, 0)) AS '2012一季报',
  MAX(IF(ENDDATE = '2012-06-30', `EPS`, 0)) AS '2012中报' 
  FROM
  STK_FIN_PerShare a 
  WHERE a.`ENDDATE` BETWEEN '2011-09-30' 
  AND '2012-06-30' 
  AND a.`STATETYPECODE` = 'A' 
  GROUP BY INSTITUTIONID,
  SYMBOL 
  ORDER BY INSTITUTIONID,
  ENDDATE ASC) f 
ORDER BY '2012中报','2012一季报','2011年报','2011三季报' DESC

(其中EPS是number类型)

------解决方案--------------------
ORDER BY 6 DESC,5 DESC ,4 DESC,3 DESC