select count() from table
括号中  如果需要满足 两个 case 怎么写

解决方案 »

  1.   

    select count(case when a=6 then 1 else (case when b=3 then 1 else 0 end) end )
    from table1
      

  2.   


    --求个数的时候条件可以放到where后面
    --例如
    select count(*) from table where a=1
    select count(*) from table where a=2
    --可以这样
    select 
    sum(case when a=1 then 1 else 0 end),
    sum(case when a=2 then 1 else 0 end)
    from tablename
      

  3.   


    是不是应该select count(case when a=6 then (case when b=3 then 1 else 0 end) else 0 end )
    from table1 这样啊