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
我想按月订购结果..请帮助我。当我这样做时,它会根据字母字符进行排序。
答案 0 :(得分: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