0
SELECT 
  CONVERT(datetime, call_start_time,100) 
    + CONVERT(datetime, call_start_time,120) as YEAR,
  SUM(call_duration) AS Total_CDR
FROM temp_txn_rated_retailcdr 
GROUP BY 
  CONVERT(datetime, call_start_time, 100) 
    + CONVERT(datetime,call_start_time,120) 
ORDER BY year DESC

我想按月订购结果..请帮帮我。当我现在这样做时,它会根据字母字符进行排序。

4

1 回答 1

0

试试这个它会为你工作。

Select Month + ' ' + YEAR as c_Year,Total_CDR
    from 
    (
    SELECT 
        MONTH(call_start_time) AS Month
        ,YEAR(call_start_time) as YEAR 
        ,SUM(call_duration) AS Total_CDR
    FROM temp_txn_rated_retailcdr 
    GROUP BY MONTH(call_start_time),YEAR(call_start_time) 
    ) tbl
    ORDER BY YEAR desc,Month DESC
于 2012-06-14T07:49:43.737 回答