如何在4gl中使用变量进行“分组" [英] How to 'group by' using variables in 4gl
本文介绍了如何在4gl中使用变量进行“分组"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过4gl查询中的表中的字段对记录进行分组?
Is there a way to group records by a field within a table within a 4gl query?
我的代码.
define variable v-invoice as inte no-undo.
define variable v-sell-price as decimal no-undo.
define variable v-cost-price as decimal no-undo.
define variable iinv as integer no-undo.
For each Order no-lock :
v-invoice = Order.tblinvoice.
v-sell-price = Order.sell-price.
v-cost-price = Order.cost-price.
iinv = iinv + Order.sell-price.
display Order.invoice Order.sell-price.
end.
谢谢
推荐答案
是的,当然可以,非常简单:
Yes, of course you can, very basic:
DEFINE VARIABLE v-sell-price AS INTEGER NO-UNDO.
DEFINE VARIABLE v-cost-price AS INTEGER NO-UNDO.
FOR EACH order BREAK BY order.invoice:
/* Sum the prices */
ASSIGN
v-sell-price = v-sell-price + Order.sell-price.
v-cost-price = v-cost-price + Order.cost-price.
/* On the last order matching this order display and reset sums */
IF LAST-OF(order.invoice) THEN DO:
DISPLAY Order.invoice v-sell-price v-cost-price.
ASSIGN
v-sell-price = 0
v-cost-price = 0.
END.
END.
这篇关于如何在4gl中使用变量进行“分组"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文