Sum Column Values

Sum Column Values

  
Hi, I have a Units(Decimal) column in my entity and want to calculate total value of all Units records? I have tried to use "sum(units) for {table}" in adv. sql query but do not know what output to use. What is the correct way to do this? 

Any help would be appreciated. 

Hi Martin,

Check out this video in our online training. It covers the usage of Advanced Queries. You'll need to create a structure for the output of the query. In your case this structure should have 1 attribute of type decimal to hold the sum(units). In the Advanced query you'll need to provide proper SQL syntax to be executed. So you should have something like:

select SUM({Entity}.[Units]) from {Entity}


Cheers
Thank you, worked like a charm! I love a nice and easy explenation.

Link to the video seems broken

André Vieira wrote:

Hi Martin,

Check out this video in our online training. It covers the usage of Advanced Queries. You'll need to create a structure for the output of the query. In your case this structure should have 1 attribute of type decimal to hold the sum(units). In the Advanced query you'll need to provide proper SQL syntax to be executed. So you should have something like:

select SUM({Entity}.[Units]) from {Entity}


Cheers

It works great, thanks!


Note: Make sure the OutPut structure (the final structure of the result) has a Data Type (characteristics) Decimal. Example:


RoomService -> Table

Amount -> RoomService Table which I want to sum

BookingId-> Colum referencing to a Booking Table

@BookingId -> Is the value you pass to the query which you want to check

SELECT SUM({RoomService}.[Amount])
FROM {RoomService}
WHERE {RoomService}.[BookingId] = @BookingId

Hope it helps