我想通过一条SQL语句返回一个记录总数,该总数为A表中ID=01的记录数 + B表中ID=02的记录数+C表中ID=03的记录数通过一条SQL语句返回,谢谢赐教!

解决方案 »

  1.   

    select count(1) from (
        select count(1) from A where id=01
        union all select count(1) from B where id=02
        union all select count(1) from C where id=03
    )
      

  2.   

    select sum(num) from (
        select count(1) as num from A where id=01
        union all select count(1) as num from B where id=02
        union all select count(1) as num from C where id=03
    )