ainulm
7th July 2014, 07:12
Hi All,
I want to calculate total in report script and i need to exclude some column.
So far i have been using this code, and it continuously displaying error. need help urgently. Thanks
Below is the sample from my code. Sorry for any mistake. im still new in this development. :(

function abc()
{

SELECT SUM(tfacr200.amth)
FROM tfacr200
WHERE tfacr200.ttyp not in ("ABC")
selectdo

endselect
}

bhushanchanda
7th July 2014, 09:49
Hi,

If you are using "sum" in your query, you need to use group by as well.

One more better way is to store the sum in one variable i.e. use binding.

Check related thread for examples:-

Thread 1 (http://www.baanboard.com/baanboard/showthread.php?t=63237)
Thread 2 (http://www.baanboard.com/baanboard/showthread.php?t=57788)
Thread 3 (http://www.baanboard.com/baanboard/showthread.php?t=52752)

And please do not double post!

ainulm
7th July 2014, 10:16
Hi Bhushanchanda,

How can i declare the amount to the report layout?
So that it can print the value correctly
Thanks for your help.

mark_h
7th July 2014, 14:53
To use the sum I usually declare a variable then use it in the query.

extern domain tcpric some.total

SELECT SUM(tfacr200.amth):some.total

Then you can print some.total on the report. Of course you can pass this variable to the report or if using the query in the report then you can print it. Just use the domain of you field.

ainulm
8th July 2014, 10:14
Hi mark_h,
Thank you for your help.