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 に答える