select count(a1) from where a1=1 group by a2

解决方案 »

  1.   

    谢谢,
    还要统计a1<>1的情况,怎么办啊,急!!!
      

  2.   

    select count(a1) from table1 group by a2
      

  3.   

    大于1:  select count(a1) from where a1>1 group by a2
    小于1:   select count(a1) from where a1<1 group by a2
    不等于1: select count(a1) from where a1<>1 group by a2
      

  4.   

    学会举一反三呀~补充:Group By 用于统计,一般与 Count() 一起用
      

  5.   

    select count(a1) from table1 group by a2
      

  6.   

    select count(a1) from table1 group by a2
      

  7.   

    呵呵,你们都误解我的意思拉.我要的是在同一行中显示,
    我已经知道怎么做了,不过还是很感谢你们。下面是具体的方法:
    select count(a1), sum(decode(a1-1,0,1,0))
    from table1 
    group by a2
      

  8.   

    用sum不是求和了吗?好像不对啊!
    select count(al)||' al=1'  from table1 where a1=1
    union all
    select count(al)||' al<>1' from table1 where al<>1
    这样行不行
    我是菜虫,多多指教
      

  9.   

    菜虫说错了, hjjkey(一悟) 写的是对的!!
    //shy