在选择列表中添加另一个 MONTH(LIFTINGDATE) 列并按列表分组
SELECT
Round(Sum(Totalamount)/Sum(totalweight),2)as AVGRATE
,DATENAME(MONTH,LIFTINGDATE)
,MONTH(LIFTINGDATE)
as [Month] from k_LiftingEntryRecords
where (liftingdate BETWEEN '2013-04-01 00:00.000' AND '2013-07-30 00:00:00.000')
group by DATENAME(MONTH,LIFTINGDATE),MONTH(LIFTINGDATE)
order by MONTH(LIFTINGDATE)
如果您需要相同的列列表,那么
SELECT AVGRATE,Month_Name FROM
(
SELECT
Round(Sum(Totalamount)/Sum(totalweight),2)as AVGRATE
,DATENAME(MONTH,LIFTINGDATE) AS Month_Name
,MONTH(LIFTINGDATE) MonthNum
as [Month] from k_LiftingEntryRecords
where (liftingdate BETWEEN '2013-04-01 00:00.000' AND '2013-07-30 00:00:00.000')
group by DATENAME(MONTH,LIFTINGDATE),MONTH(LIFTINGDATE)
) T
ORDER BY MonthNum