解决方案 »

  1.   

    price>0的个数 这个具体是怎么算的。你下面的结果怎么得到的。 第二行时间是2014吧
      

  2.   


    select company,sum(factoryprice)+sum(wholeprice)
    +sum(wholeprice) as num,time (select case when factoryprice >0 then 1 else 0 end as factoryprice,
           case when  wholeprice >0 then 1 else 0 end as wholeprice,
           case when  retailprice>0 then 1 else 0 end as retailprice,
           company,time from tablename) as  t
           group  by company,time
      

  3.   

    第二行是2014
    price>0的个数  (FactoryPrice  +WholePrice+ RetailPrice)  得到的
    比如gong            5          2014    这个5就是尿素有3个>0    碳铵1个    普通钙1个