100分求一个非SQL的统计。

cclh 2003-08-22 09:14:56
数据库Table1: 金额 日期
2003-3-4
如日期类型不对可改。
两个输入年,月的SpinEdit1,SpinEdit2;
一个按钮:procedure TForm2.Button1Click(Sender: TObject);

各位大虾帮忙做个月统计,在一个Edit中显示。
谢谢!
...全文
25 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cclh 2003-08-27
  • 打赏
  • 举报
回复
各位由于没有SQL,这些句子运行都出现Undeclared identifier:adoquery.sql不知是否能用?
我用DELPHI自有的order选4个字段,第四个为EmpNo.编了一个只对列求和的程序,可益出了。各位帮看看哪不对,
procedure TForm1.Button1Click(Sender: TObject);
var
sd:integer;
begin
with Table1 Do
begin
sd:=0;
first;
while not EOF do
sd:=sd+Fields[3].value;
next;
end;
Edit1.text:=IntToStr(sd);
end;
ASPCOMjsp 2003-08-23
  • 打赏
  • 举报
回复
应该定义为 Tdatetime ;
qianguob 2003-08-23
  • 打赏
  • 举报
回复
Undeclared identifier: 'datetime'
是否我的DELPHI7企业版出了问题


应该定义为 Tdatetime ;
dyf2001 2003-08-23
  • 打赏
  • 举报
回复
漏掉两个括号,更正如下:
adoquery.sql:=
'select sum(金额) from table where 日期 >= toDate('+
QuotedStr(spinedit1.text+'-1') + ', ' + QuotedStr('yyyy-mm-dd') +
') and 日期 < toDate('+ QuotedStr(spinedit2.text+'-1') +
', ' + QuotedStr('yyyy-mm-dd')+‘)’
dyf2001 2003-08-23
  • 打赏
  • 举报
回复
adoquery.sql:=
'select sum(金额) from table where 日期 >= toDate('+
QuotedStr(spinedit1.text+'-1') + ', ' + QuotedStr('yyyy-mm-dd') +
' and 日期 < toDate('+ QuotedStr(spinedit2.text+'-1') +
', ' + QuotedStr('yyyy-mm-dd')

oracle中
frogshero 2003-08-23
  • 打赏
  • 举报
回复
混分﹐up
frogshero 2003-08-23
  • 打赏
  • 举报
回复
monthBegin,monthend:string;
monthBegin:=yearedit.text+'-'+monthedit.text+'-01';
monthEnd:=yearedit.text+'-'+inttostr(strtoint(monthedit.text)+1)+'-01';
'select sum(金额) from table where 日期>='+quotedstr(monthbegin)+' and 日期<'+quotedstr(monthEnd);
Shiyl 2003-08-22
  • 打赏
  • 举报
回复
procedure TForm2.Button1Click(Sender: TObject);
var date,date1,date2:datetime;
begin
date1:=strtodate(spinedit1.text);
while date1<strtodate(spinedit2.text) do
begin
adoquery.sql.clear;
adoquery.sql.add('select '',金额 from table1
union
select '合计',sum(金额) from table1');
adoquery.open;
date1:=date1+1;
end;
end;
试试
cclh 2003-08-22
  • 打赏
  • 举报
回复
不知是哪出问题:
由于连接SQL出问题,我用select '合计',sum,运行时select Undeclared identifier: 'select'
用with table1 do, 时with Declaration expected but 'WITH' found
用您的var date,date1,date2:datetime; 时出现
Undeclared identifier: 'datetime'
是否我的DELPHI7企业版出了问题

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧