id                count1  count2
T0503001-1 9 0
T0503001-1 9 0
T0503001-1 9 4
C0804121    0 0
T0610003   0.016666 0
T0610003   0.016666 0
T0610003 0.016666 6
T0610003 0.016666 0
T0610003 0 0
T0610003 0.05 0
T0610003 0 0
 select 出每个id的count1大于0的个数 和count2大于0的个数

解决方案 »

  1.   


    select * from 表 where count1 >0 and count1>0 
      

  2.   

    select * from 表 where count1 >0 and count2>0 
      

  3.   

    select id ,count(count1)from Table
    where count1>0 group by id
    union
    select id ,count(count2)from Table
    where count2>0 group by id
      

  4.   


    drop table wen5161
    create table wen5161(id  varchar(50),               count1 float, count2 int)
    insert into wen5161
    select 'T0503001-1', 9 ,0  union all
    select 'T0503001-1', 9 ,0 union all
    select 'T0503001-1', 9, 4 union all
    select 'C0804121' ,  0 ,0 union all
    select 'T0610003' ,0.016666 ,0 union all
    select 'T0610003', 0.016666, 0 union all
    select 'T0610003' ,0.016666, 6 union all
    select 'T0610003', 0.016666 ,0 union all
    select 'T0610003', 0 ,0 union all
    select 'T0610003', 0.05, 0 union all
    select 'T0610003', 0, 0 select distinct id , (select count(1) from wen5161 where  count1> 0  and id = A.id),
    (select count(1) from wen5161 where  count2> 0  and id = A.id)
     from wen5161 A
    =======================C0804121 0 0
    T0503001-1 3 1
    T0610003 5 1
      

  5.   

     各位 好像都不太理解我的意思
    我要的是id对应的count1 和count2分别大于的次数 ,
    得出格式如下 id          count1   count2
               T0610003      2       3请赐教!!
      

  6.   

    SELECT COUNT(*) FROM TB WHERE COUNT1>0 AND COUNT2>0??