USE [text] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[getHcrStat1580] @wherestr varchar(200), @YMD tinyint AS BEGIN SET NOCOUNT ON; DECLARE @class varchar(200),@grpstr varchar(50),@sql nvarchar(1200),@colstr varchar(400),@table varchar(20) set @table='[NGtbhcr1580]' set @class='class=case class when ''甲'' then ''甲班'' when ''乙'' then ''乙班'' when ''丙'' then ''丙班'' when ''丁'' then ''丁班'' else '''' end' if @YMD=0 begin set @colstr='rq=YMD,FUR_NO,'+@class set @grpstr=' group by YMD,FUR_NO,class' end else if @YMD=1 begin set @colstr='rq=YM,FUR_NO,'+@class set @grpstr=' group by YM,FUR_NO,class with rollup' end else if @YMD=2 begin set @colstr='rq=YY,FUR_NO,'+@class set @grpstr=' group by YY,FUR_NO,class with rollup' end set @sql='select '+@colstr+', tll=convert(numeric(14,2),sum(tll)), rzl350=convert(numeric(8,2),sum(rz350t)/sum(tll)*100), rzl450=convert(numeric(8,2),sum(rz450t)/sum(tll)*100), rzl600=convert(numeric(8,2),sum(rz600t)/sum(tll)*100), RZPJT=convert(numeric(8,2),sum(RZPJT)/nullif(sum(rznum),0)), JPL=convert(numeric(8,2),sum(JPL)/sum(tll)*100), FGL=convert(numeric(8,2),avg(FGL)), jtmp=convert(numeric(8,2),avg(jtmp)), N230=convert(numeric(8,2),avg(N230)) from '+@table+' where YMD between '+@wherestr+@grpstr exec sp_executesql @sql,N'@colstr varchar(400)',@colstr end
时间: 2023-05-14 13:07:03 浏览: 87
list_nulls.rar_Over
这是一个 SQL 存储过程,用于从表 NGtbhcr1580 中获取数据。根据传入的参数 @wherestr 和 @YMD,可以选择按日、月或年进行汇总。返回的结果包括日期、FUR_NO、班级、总产量、350、450、600 等级的入炉率、平均热值、加热时间、N230 等数据。
阅读全文