This topic is locked

Percentages calculated from two tables on List page?

12/8/2006 8:34:29 PM
PHPRunner General questions
J
Jkelleyus author

You all have been so helpful so far.. and I've managed to build a very workable solution in just a couple of days.. AMAZING!
Now here is is another question...
I have a table in my MySql database called SCRAP. I have another called PRODUCTION. The Scrap table is related to the Production table by a Production_ID column. phpRunner relates perfectly well....
What I'd like to do is this.... the SCRAP table has a quantiity of product that was mis-manufactured... the PRODUCTION table has a quantity of the item produced on a particular day.
I want to be able to present a percentage... on the SCRAP listing page.... of scrapped vs. produced parts.
It would be something like this.... SCRAP.QTY/PRODUCTION.QTY.
Is that possible on the list page?
Thanks again for all the help.. this software is amazing...
Jake

L
larsonsc 12/8/2006

Try adding this into your SQL query for the view that creates your list page:

`scrap`.`qty`/`production`.`qty` AS "Percentage Scrapped"


Depending on where in your select statement that goes, you may need to add a comma at the end of the line. You can also change the Percentage Scrapped to whatever you want the column title to appear as.
Hope that helps.
--Shawn