with ADOQuery1 do
begin
close;
SQL.Clear;
SQL.Add('select a.CallerDN, Count(a.CallerDN) as OutNum, 0 as InNum');
SQL.Add(' from CDRDetail as a, CDRLog as b');
SQl.Add(' where a.LogID = b.ID and b.IsOut = true'
+ ' and a.BinTime >= :BinTimeFrom'
+ ' and a.BinTime <= :BinTimeTo');
SQL.Add(' group by a.CallerDN');
SQL.Add(' union select a.CalledDN, 0 as OutNum, Count(a.CalledDN) as InNum');
SQL.Add(' from CDRDetail as a, CDRLog as b');
SQl.Add(' where a.LogID = b.ID and b.IsOut = false'
+ ' and a.BinTime >= :BinTimeFrom'
+ ' and a.BinTime <= :BinTimeTo');
SQL.Add(' group by a.CalledDN'); Parameters.ParamByName('BinTimeFrom').Value
:= Edit1.Text;
Parameters.ParamByName('BinTimeTo').Value
:= Edit2.Text;
open;
end;上面的sql语句是对表CDRDetail和CDRLog根据CDRLog.IsOut的值分别进行查询,然后将
IsOut=true和IsOut=false这两种查询情况用union并起来,但是现在我查询出来只有IsOut=true
时候的数据,没有IsOut=false时候的数据,这是怎么回事?请高手帮忙看看,是不是哪里写错了?
begin
close;
SQL.Clear;
SQL.Add('select a.CallerDN, Count(a.CallerDN) as OutNum, 0 as InNum');
SQL.Add(' from CDRDetail as a, CDRLog as b');
SQl.Add(' where a.LogID = b.ID and b.IsOut = true'
+ ' and a.BinTime >= :BinTimeFrom'
+ ' and a.BinTime <= :BinTimeTo');
SQL.Add(' group by a.CallerDN');
SQL.Add(' union select a.CalledDN, 0 as OutNum, Count(a.CalledDN) as InNum');
SQL.Add(' from CDRDetail as a, CDRLog as b');
SQl.Add(' where a.LogID = b.ID and b.IsOut = false'
+ ' and a.BinTime >= :BinTimeFrom'
+ ' and a.BinTime <= :BinTimeTo');
SQL.Add(' group by a.CalledDN'); Parameters.ParamByName('BinTimeFrom').Value
:= Edit1.Text;
Parameters.ParamByName('BinTimeTo').Value
:= Edit2.Text;
open;
end;上面的sql语句是对表CDRDetail和CDRLog根据CDRLog.IsOut的值分别进行查询,然后将
IsOut=true和IsOut=false这两种查询情况用union并起来,但是现在我查询出来只有IsOut=true
时候的数据,没有IsOut=false时候的数据,这是怎么回事?请高手帮忙看看,是不是哪里写错了?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货