Jump to content
  • 0

Sum Function in Triggered Actions



In my table, I have a field for Expenses. Upon insert, I want to update the other table with the total sum of all expenses per user. 

I have set up a triggered action. However, I can't get it to work because I'm having this error when I use the Sum Function: An aggregate may not appear in the set list of an UPDATE statement. (error code: SQL157)

Can you please help?


Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @MyMelody,


I  got the same problem with you last week. The solution I thought of is to create another table. It will be like storage of whatever I insert in the main table. In the trigger, I used that table as a reference to sum up all the expenses. 

Please see the screenshot I created:



Upon Insert in the MainTbl, it will be also inserted to the Table_2 (storage table).  The total expenses is the sum of all Expenses inserted in the Table_2 per ID.


Hope this helps.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...