isnull(QuitTime,'') >或< 或者 isnull(QuitTime,'') between ... and...
where (QuitTime IS NULL)
create proc RZ_percent @T1 smalldatetime,@T2 smalldatetime,@RT1 varchar(8) as begin declare @TS1 smallint declare @TS2 smallint declare @TS smallint declare @FJS smallint declare @SJDTS smallint declare @PS float select @TS1=sum(((year(@T2)-year(FisrtTime))*365+(month(@T2)-month(FisrtTime))*30+(day(@T2)-day(FisrtTime)))) from Guest where FisrtTime>=@T1 and QuitTime is NULL and RoomID in (select RoomID from RoomInfo where RoomType=@RT1) select @TS2=sum(((year(QuitTime)-year(FisrtTime))*365+(month(QuitTime)-month(FisrtTime))*30+(day(QuitTime)-day(FisrtTime)))) from Guest where FisrtTime>=@T1 and QuitTime<=@T2 and RoomID in (select RoomID from RoomInfo where RoomType=@RT1) Set @TS=@TS1+@TS2 select @FJS=count(RoomID) from RoomInfo where RoomType=@RT1 set @SJDTS=((year(@T2)-year(@T1))*365+(month(@T2)-month(@T1))*30+(day(@T2)-day(@T1))) set @PS=(@TS/@SJDTS)/@FJS print '(入住率为:'+cast(@PS1 as varchar(10))+')' end 就是这个东东了 结果总是输出一片空白 是不是判断条件出语法错误了 可却没报错 估计是smalldatetime那些数据出问题了吧 朋友们帮我看看啊,,
where QuitTime is NULL 1楼说的对
where QuitTime is NULL
而且print '(入住率为:'+cast(@PS1 as varchar(10))+')' 这句没有这个变量@PS1
只能is null进行判断
或者:where isnull(QuitTime,'')=''
或者
isnull(QuitTime,'') between ... and...
@T1 smalldatetime,@T2 smalldatetime,@RT1 varchar(8)
as
begin
declare @TS1 smallint
declare @TS2 smallint
declare @TS smallint
declare @FJS smallint
declare @SJDTS smallint
declare @PS float
select @TS1=sum(((year(@T2)-year(FisrtTime))*365+(month(@T2)-month(FisrtTime))*30+(day(@T2)-day(FisrtTime)))) from Guest
where FisrtTime>=@T1 and QuitTime is NULL and RoomID in (select RoomID from RoomInfo
where RoomType=@RT1)
select @TS2=sum(((year(QuitTime)-year(FisrtTime))*365+(month(QuitTime)-month(FisrtTime))*30+(day(QuitTime)-day(FisrtTime)))) from Guest
where FisrtTime>=@T1 and QuitTime<=@T2 and RoomID in (select RoomID from RoomInfo
where RoomType=@RT1)
Set @TS=@TS1+@TS2
select @FJS=count(RoomID) from RoomInfo where RoomType=@RT1
set @SJDTS=((year(@T2)-year(@T1))*365+(month(@T2)-month(@T1))*30+(day(@T2)-day(@T1)))
set @PS=(@TS/@SJDTS)/@FJS
print '(入住率为:'+cast(@PS1 as varchar(10))+')'
end
就是这个东东了 结果总是输出一片空白 是不是判断条件出语法错误了 可却没报错
估计是smalldatetime那些数据出问题了吧 朋友们帮我看看啊,,
1楼说的对