select (select count(1) from T1)/(select count(1) from T2);????
select CAST((select count(*) from T1)/(select count(*) from T2) as DECIMAL(18,2))
貌似不行啊,报错了
if select count(*) from T2>0 then
select CAST((select count(*) from T1)/(select count(*) from T2);
你之前报错是因为没有查到数据?
有数据的,你确定db2可以使用这种写法,我用这种写法报语法错误
@sflik:
select CAST((select count(*) from T1)/(select count(*) from T2) as Row2) as DECIMAL(18,2) where Row2>0
@Boblim: as DECIMAL(18,2) 在里面
@Boblim: 这样? select CAST((select count(*) from T1)/((select count(*) from T2)as Row2) as DECIMAL(18,2) ) where where Row2>0
select (select count(*) from T1)/(select count(*) from T2);