-----------------------------------
--目的:多条件查询销售任务信息(销售报表)
--
--创建人:史志辉
--日期:2011.01.19
--
-----------------------------------
ALTER PROC [proc_SEL_WL_SaleMission_BY_Conditions]
(
@TheYear varchar(20),
@MissionType varchar(20),
@Audit varchar(20),
@ComId int,
@ComIds varchar(200)
)
AS
DECLARE@strSQL nvarchar(2000)
SET@strSQL=' SELECT A.*,case when A.MissionType=0THEN ''现有任务'' when A.MissionType=1 THEN ''拓展任务'' else ''未定义'' endAS
MissionTypeName, B.C_Name FROM WL_SaleMission A LEFT JOINH_Company B ON A.ComId=B.id WHERE 1=1 '
if(@TheYear!='')
begin
set@strSQL=@strSQL+' AND A.TheYear= '''+rtrim(@TheYear)+''''
end
if(@MissionType!='-1')
begin
set@strSQL=@strSQL+' AND A.MissionType='''+rtrim(@MissionType)+''''
end
if(@Audit!='-1')
begin
set@strSQL=@strSQL+' AND A.Audit= '''+rtrim(@Audit)+''''
end
if(@ComId!='-1')
begin
set@strSQL=@strSQL+' AND A.ComId= '''+rtrim(@ComId)+''''
end
if(@ComIds!='')
begin
set@strSQL=@strSQL+' AND B.id IN(' + @ComIds + ') '
end
exec(@strSQL)
GO
EXEC proc_SEL_WL_SaleMission_BY_Conditions'','-1','-1','1','1'