日期:2014-05-18 浏览次数:20449 次
create proc procname @MeterNo varchar(50), @DataTime datetime, @Qty dec(18,2) output as select @Qty=Qty from tb where MeterNo=@MeterNo and [DataTime]=@DataTime
------解决方案--------------------
create proc procname ( @meterno varchar(50), @datatime datetime ) as begin select datepart(hour,getdate()),cast(sum(qty) as decimal(18,2)) from tablename where meterno=@meterno and convert(varchar(10),[datatime],120)=convert(varchar(10),@datatime,120) group by datepart(hour,getdate()) end