select a.总看机数/b.出勤天数
from
(select id,总看机数 from 产量汇总) a,
(select id,出勤天数 from 产量汇总) b
where a.id = b.id
from
(select id,总看机数 from 产量汇总) a,
(select id,出勤天数 from 产量汇总) b
where a.id = b.id
调试欢乐多
declare @sum2 float
declare @rate ffsd
set @sum1=select 总看机数 from 产量汇总
set @sum2=select 出勤天数 from 产量汇总
if @sum2>0
begin
set @rate=@sum1/@sum2
print @rate
end
呵呵.
select 出勤天数 from 产量汇总
现在要求 总看机数/出勤天数,该怎么做?
select 总看机数,出勤天数,总看机数/出勤天数 as 结果 from 产量汇总
或
select a.总看机数/b.出勤天数
from
(select 总看机数 from 产量汇总) a
,(select 出勤天数 from 产量汇总) b
但不能用pengdali(大力 V2.0) 的select 总看机数,出勤天数,总看机数/出勤天数 as 结果 from 产量汇总要是分母为零就会出错!用yangvxin1(小杨)的好,做一个存储过程,再用OUTPUT参数调用
存储过程的返回值。