按时间查询并统计数据库的问题

tianzhejt 2005-04-12 02:26:35
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
with adoquery1 do
begin
Close;
SQL.Clear;
SQL.Text := 'select riqi,suxue from cheji ' +
'where riqi = ''' + FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime) +''''
and ????????;
Open;
end;
end;

我要把DateTimePicker1选中的时间在dbgrid中显示出来,并且把数学这个字段下的所有数据求和,
该如何实现,请帮助。
...全文
113 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianzhejt 2005-04-12
  • 打赏
  • 举报
回复
and ?????? 这里就是我想要加的求和的语句。
XueYan 2005-04-12
  • 打赏
  • 举报
回复
阿,你可以使用adoquery1动态创建字段,就是使用计算出来的字段
xjjrocker 2005-04-12
  • 打赏
  • 举报
回复
SQL.Text := 'select riqi,suxue from cheji ' +
'where riqi = ''' + FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime) +''''
and ????????;
=======不太明白你的意思,可能理解有误=========>
SQL.add('select riqi,sum(suxue) as 新栏位名 from cheji');
SQL.add('where riqi = FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime)');

是这个意思吗,呵呵
liuqifeiyu 2005-04-12
  • 打赏
  • 举报
回复
with adoquery1 do
begin
SQL.Text := 'select '+#39+FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime) +#39+' as choseriqi,sum(suxue) as sumsuxue,riqi,suxue from cheji ' +
' where riqi = ''' + FormatDateTime('yyyy-mm-dd',DateTimePicker1.DateTime) +''''
and ????????
group by riqi,suxue';
Open;
end;

2,498

社区成员

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

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