IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[report_46_data]') AND type = 'P')
DROP PROCEDURE [dbo].[report_46_data]
GO
CREATE PROCEDURE report_46_data
@cmpid int,@branchid int,@userdpid int,@userotid int,@useruid int,@tableid varchar(8000),@objids varchar(8000),@pagesize int,@qry_date1 varchar(512)
,@qry_date2 varchar(512)

AS
BEGIN
 set nocount on 

declare @dataIds table(objid int)
if @objids!='_NONE' and @objids!='_none_' and @objids!='' 
insert into @dataIds(objid)
select value from dbo.fn_split_int(@objids)
create table #temp (
     tableid varchar(10),
     ord_jclx varchar(500),--检查类型
 ord_lrbz varchar(1000),--当月出现问题
     ord_bhgs int DEFAULT 0,--不合格次数
 ord_sywt int DEFAULT 0,--所有问题数
ord_lz decimal(18,2) default 0.0 --所有问题占比   
 )
 
 insert into #temp (tableid,ord_jclx,ord_lrbz,ord_bhgs)
 select 'tb_report1',ord2_jclx ,ord2_lrbz_bak,count(10) 
 from order_272_2
 where ord2_jcqk = '不合格'
 and ord2_date >= @qry_date1 + ' 00:00:00' 
 and  ord2_date <= @qry_date2 + ' 23:59:59'
 group by ord2_jclx ,ord2_lrbz_bak,ord2_jcqk



 update #temp set ord_sywt = (select sum(ord_bhgs) from #temp)


 update #temp set ord_lz = CONVERT(decimal(18, 2),ord_bhgs * 1.0 / ord_sywt)


 select * from #temp
END