急 很急 急得很 救命~~!
为表写一个通用存储过程,传入表具编号(MeterNo)和日期(Dt),可以返回该表的24小时的数据(1—24小时,24条记录),数值(Qty)保留两位小数。
表如下:
DANo(char(32),not null)
MeterNo(char(20),not null)
MeterType(char(4),not null)
DATime(datetime,not null)
LogTime(datetime,not null)
DAType(char(3),null)
Qty(decimal(18,6),not null)
Qty01(decimal(18,6),not null)
Qty02(decimal(18,6),null)
Note(nvarchar(50),null)
[解决办法]
create proc procname@MeterNo varchar(50),@DataTime datetime,@Qty dec(18,2) outputas select @Qty=Qty from tb where MeterNo=@MeterNo and [DataTime]=@DataTime
[解决办法]
create proc procname( @meterno varchar(50), @datatime datetime)asbegin 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