两位都说[red]起点不同[/red],难道BORLAND和MS没有一个标准协议的吗?天哪,这可叫我们如何是好?!
但我尝试用FLOAT比较,却在SQL ANALYZER都得不到数据?!
不如贴我的存储过程出来,蓝色的是改为FLOAT比较用的.
CREATE PROCEDURE [MonthlyReport] @T char(15),@M char(20),@V char(10),@frmD datetime,@toD datetime
[blue]---CREATE PROCEDURE [MonthlyReport] @T char(15),@M char(20),@V char(10),@frmD float,@toD float[/blue]
AS
/*
Purpose :
从DAILYCPK表里统计每月有多少项的cp&cpk >1.33 or <=1.33
*/
declare @Gcp int --Good Cp >1.33
declare @Bcp int --Bad Cp <=1.33
declare @GCpk int
declare @BCpk int
declare @curDate datetime
[blue]---declare @curDate float[/blue]
set nocount on
--临时表
create table #MonthlyRpt(
ActionDate Datetime,
GoodCp int,
BadCp int,
GoodCpk int,
BadCpk int
)
set @curDate=@FrmD
while @curDate<=@toD
begin
set @GCp=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(char(8),Actiondate,112)=convert(char(8),@curDate,112) AND cp>1.33 )
set @BCp=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(char(8),Actiondate,112)=convert(char(8),@curDate,112) AND cp<=1.33 )
set @GCpk=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(char(8),Actiondate,112)=convert(char(8),@curDate,112) AND cpk>1.33 )
set @BCpk=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(char(8),Actiondate,112)=convert(char(8),@curDate,112) AND cpk<=1.33 )
if (@Gcp<>0 or @Bcp<>0 or @GCpk<>0 or @BCpk<>0 )
begin
insert into #MonthlyRpt values(@curDate,@Gcp,@Bcp,@GCpk,@Bcpk)
end
set @curDate=@curDate+1 --NEXT DAY
continue
end
[blue]/*
set @curDate=@FrmD
while @curDate<=@toD
begin
set @GCp=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(float,Actiondate)=@curDate AND cp>1.33 )
set @BCp=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(float,Actiondate)=@curDate AND cp<=1.33 )
set @GCpk=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(float,Actiondate)=@curDate AND cpk>1.33 )
set @BCpk=( select count(*) from dailycpk where modeltype=@T and model=@M and Ver=@V and convert(float,Actiondate)=@curDate AND cpk<=1.33 )
if (@Gcp<>0 or @Bcp<>0 or @GCpk<>0 or @BCpk<>0 )
begin
insert into #MonthlyRpt values(@curDate,@Gcp,@Bcp,@GCpk,@Bcpk)
end
set @curDate=@curDate+1
continue
end
*/[/blue]
set nocount off
select * from #MonthlyRpt order by ActionDate
//////////////////////////////////////////////////////