This topic is locked

View As Custom Field to display averages?

10/12/2007 8:56:36 AM
PHPRunner General questions
H
hlewis author

Hi,

Just a quick pointer needed really. In the Visual Editor I want to customise a field so that it shows the average for all numeric values in that column/field. What needs to go in as custom code?
Thanks

Alexey admin 10/15/2007

Hi,
proceed to the "Fields order and totals" tab in PHPRunner, choose your field there and select AVERAGE in the Totals type box.

H
hlewis author 10/15/2007

Alexey, thanks for the response. I notice this is only possible on the List page. I was actually after displaying averages on the view page.
The scenario is for a listings website - think Ebay and it will make sense.
I have four tables Fave Listings, Listings, Listing Details and Listing Details Feedback - a Listing can have multiple Listing Details (think relationship between Invoice and Invoice Items). Using the joins between the four tables I am able to query and pull in info onto the view page effectively showing as a single record the linked data between Fave Listings, Listings and Listing Details. With the Listing Details Feedback, you have a many to one relationship (many feedback to one listing details) and this is where I want to show an average I want to average all of the feedback columns so I can display something like '3.5 out of 5', where the 3.5 would be the average of all the feedback for the relevant Listing Details record.
Hope that makes sense!

Alexey admin 10/17/2007

I see what you saying.

You can add a subquery field with average feedback rate to your table on the Edit SQL query tab in PHPRunner.
I.e.

select

...

(select avg(rate) from `Listing Details Feedback` where listingID = ...) as avgrate,

...