一个统计记录数的问题? 我一表 t1,(id,title,passed) 用一句sql语句统计出记录总数 和 passed = 1 的记录总数! 其中 passed为bit型!

解决方案 »

  1.   

    select * from 
    (select count(1) as 总数 from t1) t1,
    (select count(1) as passed_1_总数 from t1 where passed = 1)t2
      

  2.   

    select count(1),sum(case when passed=1 then 1
                             else 0
                             end) from t1
      

  3.   

    select
    count(*)
    (select count(*) from t1 where passed=1)
    rom t1--一句就是这样,有意义么??
      

  4.   

    select
    count(*)
    (select count(*) from t1 where passed=1)
    from t1--from没拼全