比如说,邮件总数/总金额
要用到count(*)/sum(*)
把这两个合成一个字段显示,怎么合呀

解决方案 »

  1.   


    select id,
           count(*)/(select sum(..) from tb)
    from tb
    group by id
      

  2.   

    select id,
           count(*)/(select sum(..) from tb)
    from tb
    group by idcreate table tb(A varchar(10),B decimal(18,1))
    insert into tb values('A' ,       1)
    insert into tb values('B' ,       2)
    insert into tb values('C' ,       3)
    goselect cast(count(*) / sum(b) as decimal(18,2)) from tbdrop table tb/*
                         
    -------------------- 
    .50*/
      

  3.   

    http://blog.csdn.net/jinjazz/archive/2009/09/03/4516845.aspx
      

  4.   

    select id,
           count(*)/(select sum(..) from tb)
    from tb
    group by id
      

  5.   

    ltrim(count(opscwbid)+'/'+ltrim(sum(receivablefee)))
    报错
    服务器: 消息 245,级别 16,状态 1,行 1
    将 varchar 值 '/' 转换为数据类型为 int 的列时发生语法错误。
      

  6.   

    ltrim(count(opscwbid))+'/'+ltrim(sum(receivablefee)) 
      

  7.   

    ltrim 
    分別用在裡面去
      

  8.   

    case when sum(ff)!=0 then ltrim(count(*))+'/'+ltrim(sum(ff)) end
      

  9.   

    select id,colname=count(*)/sum(*)  from tb  group by  id
      

  10.   

    ltrim(count(opscwbid))+'/'+ltrim(sum(receivablefee))