SQL "GROUP BY" to ABL conversion

Posted by Stefan Marquardt on 12-Sep-2016 07:58

Is there a simple ABL equivalent for this SQL statement:
SELECT a,b,c,d,e,f,g,sum(h) from ... group by a,b,c,d,e,f,g

I found some aggregate functions in the doc but they are difficult to understand - to be honest.

All Replies

Posted by Marco Mendoza on 12-Sep-2016 08:08

FOR EACH xxxx NO-LOCK

BREAK BY a  BY b  BY c   BY d   BY e BY f BY g:

DISPLAY a b c d e f g h(TOTAL).

END.

Posted by marian.edu on 12-Sep-2016 09:48

check out accum function or accumulate statement (doh, how bout ambiguous syntax)… those should work with last-of on your right most group field.


for each … break by a by b by c by d by e by f by g:
if last-of (g) then
display a b c d e f g accum total h.
end.
 
Marian Edu

Acorn IT 
+40 740 036 212

Posted by Stefan Marquardt on 13-Sep-2016 07:33

o.k, I aggregated both code example into this:

for each .. break by a by b by c by d by e by f by g:

if last-of(g) then

 disp a b c d e f g h(total).

end.

This thread is closed