sql="select COUNT(*) as wzzs from TOPIC where ROOMID not in(0,5) and DELid=0"
rs.open sql,conn,3,3
wzzs=rs("wzzs")rs.close
sql="select COUNT(*) as ttzs from TOPIC where ROOMID in(5) and DELid=0"
rs.open sql,conn,3,3
ttzs=rs("ttzs")rs.close
sql="select COUNT(*) as xszs from TOPIC where ROOMID in(0) and DELid=0"
rs.open sql,conn,3,3
xszs=rs("xszs")

解决方案 »

  1.   

    select(select COUNT(*) as wzzs from TOPIC where ROOMID not in(0,5) and DELid=0)as wzzs,
    +"(select COUNT(*) as wzzs from TOPIC where ROOMID not in(0,5) and DELid=0)as ttzs,"
    +"(select COUNT(*) as wzzs from TOPIC where ROOMID not in(0,5) and DELid=0)as xszs"
      

  2.   

    可以,
    1:如果数据库是sql serverselect sum(case when ROOMID not in(0,5) then 1 else 0) as wzzs 
           ,sum(case when ROOMID  in(5) then 1 else 0) as ttzs 
           ,sum(case when ROOMID  in(0) then 1 else 0) as xszs 
     from TOPIC 
    where DELid=02:如果是access数据, 就用iif函数
      

  3.   

    对不起,上面else 后少了 'end'
      

  4.   

    我用的access数据库,则么写?俺菜!
      

  5.   

    2:如果是access数据, 就用iif函数select sum(iif((ROOMID not in(0,5)),1,0) ) as wzzs 
           ,sum(iif((ROOMID  in(5)),1,0) ) as ttzs 
           ,sum(iif((ROOMID  in(0)),1,0) ) as xszs 
     from TOPIC 
    where DELid=0
      

  6.   

    access不会支持的 必须分开写
      

  7.   

    直接写
    select COUNT(*) as wzzs,
    (select COUNT(*) from TOPIC where ROOMID in(5) and DELid=0) as ttzs,
    (select COUNT(*) from TOPIC where ROOMID in(0) and DELid=0) as  xszs 
    from TOPIC where ROOMID not in(0,5) and DELid=0速度可能会慢点,但是肯定是可以的