Is there a way to group records by a field within a table within a 4gl query?
My code.
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.
Thank you
Actually this is what the ACCUMULATE STATEMENT and the ACCUM function are meant for. I find the exact syntax for those somewhat hard to remember (and sometimes difficult to understand even after reading the online help), so I often resort to accumulating the variables myself like in Jensd's answer. The code for your example should look something like this (syntax-checked but not tested):
Yes, of course you can, very basic: