declare @a int select @a=(select count(*) from mb where e=1 and f=2 and g=3 group by e,f,g) 
declare @b int select @b=(select count(*) from mb where e=4 group by e) 
declare @c decimal(4,2) 
--这里
select @c=@a*1.00/@b 
-------------------------------
select @c 

解决方案 »

  1.   

    或者有一个定义为decimal.
    或者写成:
    select @c=@a*1.00/@b 
      

  2.   

    declare @a int select @a=8 
    declare @b int select @b=11
    declare @c decimal(4,2) ,@d decimal(4,2) select @c=@a/@b ,@d = @a*1.0/@b select @c ,@d
    --------------------------------------- ---------------------------------------
    0.00                                    0.73
      

  3.   

    declare @a int select @a=(select count(*) from mb where e=1 and f=2 and g=3 group by e,f,g) *1.00
    declare @b int select @b=(select count(*) from mb where e=4 group by e) *1.00
    declare @c decimal(4,2) select @c=@a/@b select @c 
      

  4.   

    declare @a dec(4,2)select @a=(select count(*) from mb where e=1 and f=2 and g=3 group by e,f,g) *1.00
    declare @b dec(4,2)select @b=(select count(*) from mb where e=4 group by e) *1.00
    declare @c decimal(4,2) select @c=@a/@b select @c modify