sql高手请指教!!!
zhngk 2003-10-27 06:39:35 要做一个查询,先查出各区域的终端总数,然后再查出mian_termianl_cnt<3的终端数。
结果如下:
bureau_no mian_terminal_cnt mian_terminal_cnt<3
-------------------------------------------------------
000921 44 3
000922 55 30
select a.bureau_no,sum(b.main_terminal_cnt) --统计各分站主终端数
from tcm_user a,tba_tv_card_ask b
where a.user_id=b.user_id
and a.finish_flag='1'
and a.state='1'
and a.user_seq=0
and a.user_id=b.user_id
and b.sequ=0
--and b.main_terminal_cnt<3
group by a.bureau_no