大家好,现在在sql里测试以下语句可以通过
select * from mysoft_overtime
where workid='1787' and tdate between '2008-06-20' and '2008-06-21'
union all
select null,'加班总计',null,sum(daycount) from mysoft_overtime
where workid='1787' and tdate between '2008-06-20' and '2008-06-21'结果为:
id workid tdate daycount
13 1787 2008-06-20 110
null 加班总计 null 110但在delphi写以上语句时就无法通过:
with adoquery1 do
begin
close;
prepared:=false;
sql.clear;
sql.add('select * from mysoft_overtime where workid='1787' and tdate between '2008-06-20' and '2008-06-21'');
sql.Add('union all');
sql.add('select null,'加班总计',null,sum(daycount) from mysoft_overtimewhere workid='1787' and tdate between '2008-06-20' and '2008-06-21'')
prepared:=true;
open;
end;现在出现的问题是:编译时会提示以下错误
project project1.exe exception class EOLeException with message "incorrect syntax near th keyword 'union'.rpocess stopped.use step or run to continue.
select * from mysoft_overtime
where workid='1787' and tdate between '2008-06-20' and '2008-06-21'
union all
select null,'加班总计',null,sum(daycount) from mysoft_overtime
where workid='1787' and tdate between '2008-06-20' and '2008-06-21'结果为:
id workid tdate daycount
13 1787 2008-06-20 110
null 加班总计 null 110但在delphi写以上语句时就无法通过:
with adoquery1 do
begin
close;
prepared:=false;
sql.clear;
sql.add('select * from mysoft_overtime where workid='1787' and tdate between '2008-06-20' and '2008-06-21'');
sql.Add('union all');
sql.add('select null,'加班总计',null,sum(daycount) from mysoft_overtimewhere workid='1787' and tdate between '2008-06-20' and '2008-06-21'')
prepared:=true;
open;
end;现在出现的问题是:编译时会提示以下错误
project project1.exe exception class EOLeException with message "incorrect syntax near th keyword 'union'.rpocess stopped.use step or run to continue.
解决方案 »
- 这个图片与XML结合的问题该如何解决?
- dbgrid 或dbgrideh标题分两行,要怎么设,那位大大帮忙下啊
- 救命啊,否则研究生就毕不了业了!!!
- decimal字段爲何不能保存5位小數?
- DELPHI透明控件代码,求VB的实现方法
- 如何定义一个标准的接口,开放式调用问题
- 电脑书籍下载好网站,推荐!http://www.studydown.com/bbs/z_adv_get.asp?get=5229
- delphi播放网络电台并记录,急求解决方法!
- 关于dbgrideh
- 我的DELPHI程序为何打不出来?
- 求助,如何在delphi中添加TCP socket 组件
- 急了.高分求教treeviewer和数据库的连接
然后把SQL语句截出来,看一下,执行结果在哪出的错。
应该不难查的
begin
close;
prepared:=false;
sql.clear;
sql.add(' select * from mysoft_overtime where workid=''1787'' and tdate between''2008-06-20'' and ''2008-06-21''');
sql.Add(' union all');
sql.add(' select null,''加班总计'',null,sum(daycount) from mysoft_overtimewhere workid=''1787'' and tdate between ''2008-06-20'' and ''2008-06-21''');
prepared:=true;
open;
end;
谢谢大家!
select * from(
....
) group by