我正在寻找给定月份和所有设备代码的最后一个仪表读数,这些设备代码在字段meter_number中的值为“1”。
SELECT [Company_Code]
,[Equipment_Code]
,[Meter_Number]
,Max([Transaction_Date]) Last_Tran
,max([meter_reading])
FROM [Forefront].[dbo].[EC_METER_HISTORY_MC]
where [Meter_Number] = '1' and [Transaction_Date] < '20130101'
group by [Company_Code]
,[Equipment_Code]
,[Meter_Number]
给我带来了结果,但我只想要meter_reading 字段,所以我可以在水晶报告中使用它。