cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating the average for a set of values

Former Member
0 Kudos

Hi,

Please could someone tell me how to calculate the average for a set of values in the database.

I tried out the simple statistics and aggregate functions. But did not yield any results.

Please do give in details about the mapping using the simple/aggregated function.

Reply a.s.a.p

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Vaishali,

I would agree with Rick.. you can handle this very well within the database query. Depending on what database server you are using, AVG and SUM are built-in functions for Oracle and SQL Server.

Example: SELECT AVG(column1), SUM(column2) FROM table

If you want other columns, you must use a GROUP BY like

SELECT Column0, AVG(column1), SUM(column2) FROM table GROUP BY Column0

- John

Former Member
0 Kudos

In SQL, can't you simply use something like:

SELECT SUM(Column) / COUNT(Column) AS AverageValue FROM Table

Rick

Former Member
0 Kudos

Vaishali

It is possible to calculate Average for a set of Values with the help of the actopn block <b>Aggregate Statistics</b>, if the property is configured in the Logic Editor in proper way

Suppose, u hv the set of values in the column with name <b>Value</b> in the table in the Database

Step 1 : Get this set of values by Query Action Block or something like that which will provides the set of values. Say that Query is named <b>GetValues</b>

Step 2 : Use Aggregate Statistics action under that Query Action, Right Click > Configure > XPath Expression as follows

<b>GetValues.Results{/Rowsets/Rowset/Row/Value}</b>

Step 3 : In the same action above, Right Click > Links > Logic Editor > Right Side Panel > Node (Average) is mapped with the expression <b>GetValues.Results{/Rowsets/Rowset/Row/Value}</b>

Also directly u can use SQL defined functions Sum, Count etc to get Average, if the database is defined in SQL.

Please feel free to ask furthers with enough details with steps if u still face some probs while doing as above

Regards

Som