IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[report_3_data]') AND type = 'P')
DROP PROCEDURE [dbo].[report_3_data]
GO
CREATE PROCEDURE report_3_data
@cmpid int,@branchid int,@userdpid int,@userotid int,@useruid int,@tableid varchar(8000),@objids varchar(8000),@pagesize int,@qry_cjsj1 varchar(512)
,@qry_cjsj2 varchar(512)
,@qry_cjyg 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)
select 'tb_report1' tableid, ord_creator,ord_sfcj,ord_ddzt,count(ord_creator) ord_count 
from order_239 
where  ord_createdpid =  @userdpid and ord_status in ('已完成','客户到店')  and ord_sfcj != ''
and ord_cjsj >= @qry_cjsj1 + ' 00:00:00' and  ord_cjsj <= @qry_cjsj2 + ' 23:59:59'  
and (@qry_cjyg = '' or ord_creator = @qry_cjyg)
group by ord_creator,ord_sfcj,ord_ddzt
order by ord_creator



END