Ro_Bu
(Ro Bu)
March 3, 2021, 10:45am
1
Hi together,
I have some issues implementing a codeless logic for calculating the SUM of a database column.
Table: “stocks” includes the column “result”. With my logic I’m currently trying to iterate the table and summarize the value (result). The problem is I’m not sure how to use the “Load table objects”-block.
I hope somebody can help me out with that “issue”.
Best Regards
Roman
Hi @Ro_Bu !
“Load Table objects” block uses BackendlessDataQuery uder the hood to load objects from specified table. In your case you should use aggregation function in props to obtain desired result
I recommend you to check our documentation about Codeless Data API - Backendless Codeless Development Guide
Also for better understanding how to build where and having clauses you can check this documentation
Search with the Where Clause - Backendless SDK for JavaScript API Documentation
Regards, Andriy
Ro_Bu
(Ro Bu)
March 3, 2021, 11:16am
3
Hi @Andriy_Konoz
do you have an example how “aggregation function in props to obtain desired result” works with the codeless logic?
BR
Roman
Hi Ro,
What is the name of the column you need to calculate the sum of?
Regards,
Mark
To obtain avarage value for field in table you can use next construction
I have made it as return value of service but you can save this value to your variable instead
Regards, Andriy
Ro_Bu
(Ro Bu)
March 5, 2021, 1:56pm
7
Hi Andriy,
I’ve tried to transfer your example into my logic. Seems I still have some issues. Please find my current on click logic here:
Could you please give me further hints what is wrong here.
Regards,
Roman
Hi Roman,
Could you please describe what issues you are having?
Regards,
Mark
Ro_Bu
(Ro Bu)
March 5, 2021, 3:14pm
9
Hi Mark,
the current issue is that I’m still not able to sum up my column from the table.
I tried to rebuild the example of Andriy for my case. But this on click event does not work. If I click on my button nothing happen with this logic.
Regards,
Roman
Have you tried running the same query in REST Console in Backendless Console? I recommend starting there first to make sure you get the expected data.
Hello @Ro_Bu ,
if you specify just sum(result)
properties, then you’ll receive value in a sum
field:
If you would like to receive value in a result
field, specify an alias - sum(result) as result
:
Regards,
Stanislaw