on 09-18-2007 12:04 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In SQL, can't you simply use something like:
SELECT SUM(Column) / COUNT(Column) AS AverageValue FROM Table
Rick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.