with dmfrm.ADOQuery9 do
begin
close;
sql.Clear;
sql.Add('select siminfor.callerid,(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b and calllist.ratetype=1) as 市话合计,');
sql.add('(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b and calllist.ratetype=2) as 长途合计,');
sql.add('(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b and calllist.ratetype=5) as 拨入合计,');
sql.add('(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b) from siminfor as 总计合计');
dmfrm.adoquery9.Parameters[0].Value:=strtodatetime(formatdatetime('yyyy-mm-dd',strtodate(combobox2.text+'-'+combobox3.Text+'-01'))+' '+formatdatetime('hh:nn:ss',strtotime('00:00:00')));
dmfrm.adoquery9.Parameters[1].Value:=strtodatetime(formatdatetime('yyyy-mm-dd',strtodate(combobox2.text+'-'+combobox3.Text+'-31'))+' '+formatdatetime('hh:nn:ss',strtotime('23:59:59')));
open;
end;
access功能怎么这么弱呀,我的数据库里有数据怎么查不出结果,是不是我的代码错了
begin
close;
sql.Clear;
sql.Add('select siminfor.callerid,(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b and calllist.ratetype=1) as 市话合计,');
sql.add('(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b and calllist.ratetype=2) as 长途合计,');
sql.add('(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b and calllist.ratetype=5) as 拨入合计,');
sql.add('(select sum(pay) from calllist where calllist.callerid=siminfor.callerid and calllist.starttime>=:a and calllist.endtime<=:b) from siminfor as 总计合计');
dmfrm.adoquery9.Parameters[0].Value:=strtodatetime(formatdatetime('yyyy-mm-dd',strtodate(combobox2.text+'-'+combobox3.Text+'-01'))+' '+formatdatetime('hh:nn:ss',strtotime('00:00:00')));
dmfrm.adoquery9.Parameters[1].Value:=strtodatetime(formatdatetime('yyyy-mm-dd',strtodate(combobox2.text+'-'+combobox3.Text+'-31'))+' '+formatdatetime('hh:nn:ss',strtotime('23:59:59')));
open;
end;
access功能怎么这么弱呀,我的数据库里有数据怎么查不出结果,是不是我的代码错了
看一下出现的是什么?
检查一下你的SQL语句。
把语句放到ACCESS中去执行。
看看对不对?
因为你加得太多。
不太明白,你的语句。
ACCESS的SQL解析没有SQL SERVER那么好,需要很标准的SQL