我有数据表Table1 ,table 1中字段为:BH  , Tprq  ,Kssj  Jssj ....
数据为:
 001     2006-09-06  2006-09-06 14:14:21   2006-09-06 15:14:21   002     2006-09-14  2006-09-06 12:14:21   2006-09-06 22:14:21 
 
 003     2006-09-06  2006-09-06 20:14:21   2006-09-06 21:14:21   ...     .....         ....                 ...... 数据表  Table2   table2 中字段为:Id  , Bh  ,MC   Zt .... 
数据为:
 1    002       dsfsd       '0'
 2    002        fffff      '1'
 3    003         deeeee     '2'
 4    003         eeee       '1'我想统计两表中 2006-09-06  的记录条数  并且要统计 其中的zt(状态)=1的记录条数,请问该如何做?谢谢!

解决方案 »

  1.   

    select * from table1 where (tprq=:dd)and(bh in (select bh from table2 where zt='1'))
    dd为参数,引入2006-09-06即可
    具体为
    query1.params.paramsbyname('dd').asstring:='2006-09-06';
    open即可
      

  2.   

    declare @BHC int
    declare @ZTC int
    select table1.BH,table2.zt from table1,table2 where table1.bh=table2.bh and bh='2006-09-06'set @BHC=(select count(*) from cc )
    set @ZTC=(select count(*) from cc where zt = '1')
    as cc
    select @BHC as BHCOunt, @ZTC as ZTis1Count
    没有试验过,尽供参考