How to SUM SQLExp query?
Hello everyone,
Please, could anyone tell me how to add sum function in the next query?
[
SQLExp('select anDiscount from the_move where ackey='''+<qReportIzpis."acKey">+''' ')
]
In the FR page i normally get anDiscount for every article, but in the next dataset I want to get sum of all articles that I've got after execution of that query.
Thanks in advance...
Please, could anyone tell me how to add sum function in the next query?
[
SQLExp('select anDiscount from the_move where ackey='''+<qReportIzpis."acKey">+''' ')
]
In the FR page i normally get anDiscount for every article, but in the next dataset I want to get sum of all articles that I've got after execution of that query.
Thanks in advance...
Comments
select
anDiscount,
(select
SUM(anDiscount)
from the_move where ackey='''+<qReportIzpis."acKey">+'''
) AS DISCOUNT_TOTAL
from the_move where ackey='''+<qReportIzpis."acKey">+'''
Of course this will be quite inefficient as the totalling query will run for every row.
You could get rid of the second select:
select
anDiscount,
SUM(anDiscount) AS DISCOUNT_TOTAL
from the_move where ackey='''+<qReportIzpis."acKey">+'''