select int(item),sum(quantity) as quantity,sum(amount) as amount,description from details
group by int(item),description //必须加上description
order by int(item)
group by int(item),description //必须加上description
order by int(item)
解决方案 »
- 又出错了,怎么做转换啊![DCC Error] download.dpr(19): E2003 Undeclared identifier: 'HKEY_LOCAL_MACHINE'
- 求字符串长度
- 100分求解dcu文件问题,高手救命(up有分)
- 有没有类excel的表格控件?
- 急求combobox解决方法
- 如何使用hook,或者其他方法得到对方程序中文本框的内容。--100fen
- group by 产品名称,规格,价格不明白分组有什么作用
- 请问DELPHI中如何捕捉所有的异常?
- sendmessage和postmessage这两个函数作用有什么区别,该怎么用?
- 华硕P2B主板怎么装联想商博士6xxx的内猫,猫是好的,可插上后怎么也找不着,怎么办?
- 谁知道有比较好用的,中文的制作帮助的软件?
- 为什么线程占用cpu时间如此严重?
procedure TfrmPrintChoice.DetailsTotal;
begin
with adodtstReportTotal do
begin
close;
commandText:='select int(item),sum(quantity) as quantity,sum(packnum) as packnum,'
+'sum(amount) as amount,sum(gross) as gross,sum(net) as net,'
+'sum(meas) as meas,description from details where invoice_id='
+ ''''+frmDocument.DBEdit1.text+''''
+ 'group by int(item),description order by int(item)';
open;
end;
这个是什么意思??要作什么??
如果不行,把你的库结构贴出来看看.
求和结果不对可能是因为先以int(item)分组,后以description分组的缘故.建议不要加上description了.鱼和熊掌不可得兼!!!!!!
也许是你的invoice_id取值出错了吧?? 造成了没有返回结果集建议调试你的frmDocument.DBEdit1.text
item float
amount float
quantity float
packnum int
gross float
net float
meas float
invoice_id char
description charitem description quantity amount gross net meas
----- ----------- -------- ------ ----- ---- ----
1.0 SHOES
1.1 9021 3000 50000 300 280 5
1.2 9022 5000
item float
amount float
quantity float
packnum int
gross float
net float
meas float
invoice_id char
description char表details的数据为:
item description quantity amount gross net meas
----- ----------- -------- ------ ----- ---- ----
1.0 SHOES
1.1 9021 3000 50000 300 280 5
1.2 9022 5000 80000 500 300 6
2.0 HAT
2.1 8921 3000 50000 200 180 3
2.2 8965 4000 60000 350 300 5我要的结果集为:
item description quantity amount gross net meas
----- ----------- -------- ------ ----- ---- ----
1.0 SHOES 8000 130000 800 580 11
2.0 HAT 7000 110000 550 480 8
Item float
amount float
quantity float
packnum int
gross float
net float
meas float
invoice_id char
description char
Type_id char |Type的表结构:
Type_id char
Type char表details的数据为:
item description quantity amount gross net meas Type_id
----- ----------- -------- ------ ----- ---- ---- -------
1.1 9021 3000 50000 300 280 5 1
1.2 9022 5000 80000 500 300 6 1
2.1 8921 3000 50000 200 180 3 2
2.2 8965 4000 60000 350 300 5 2表Type的数据为:
Type_id Type
------- ------
1 SHOES
2 HAT這樣查詢起來應該沒問題了吧