This topic is locked
[SOLVED]

 use fields in calculations

4/10/2018 2:08:56 AM
PHPRunner General questions
J
jackheitzer@gmail.com author

Hi all,
How do I use fields from different tables in calculations?
I have one table with the number of events per month (SELECT COUNT(number_of_events)...) and another table with the percentage (100%, 87.5%, 43%....) an entry will attend. How can I combine these values in a new field?
All the best,
Jack

admin 4/10/2018

This info is not enough.
Show us an example of data in both tables and also what kind of results you expect your query to return.

J
jackheitzer@gmail.com author 4/11/2018

Hi,
I'm sorry my question wasn't put clear enough. Let me try again.
I have a table of events:


SELECT COUNT(ID) FROM SHOW WHERE YEAR(datum) = YEAR(CURDATE()) AND MONTH(datum) = MONTH(CURDATE());


gives me the number of events for this month.
In another table names and percentage are stored.


I would like to create a (new) field where the percentage is multiplied by the number of events (from the first table) which would give the number of events each person is going to attend in this month.
I hope this makes more sense...
Thanks for your patience,
All the best,
Jack

J
jackheitzer@gmail.com author 4/16/2018



Hi,
I'm sorry my question wasn't put clear enough. Let me try again.
I have a table of events:

SELECT COUNT(ID) FROM SHOW WHERE YEAR(datum) = YEAR(CURDATE()) AND MONTH(datum) = MONTH(CURDATE());


gives me the number of events for this month.
In another table names and percentage are stored.

I would like to create a (new) field where the percentage is multiplied by the number of events (from the first table) which would give the number of events each person is going to attend in this month.
I hope this makes more sense...
Thanks for your patience,
All the best,
Jack


Does anybody have any tips?
Jack

Y
YCH 4/16/2018



Does anybody have any tips?
Jack


What does the "percentage" in your second table really represent? How did you calculate the "percentage" ?

J
jackheitzer@gmail.com author 4/16/2018



What does the "percentage" in your second table really represent? How did you calculate the "percentage" ?


The percentage in the 2nd table represents the percentage of the number of shows each person plays per month. 100% plays all the shows, 50% plays half the shows. This number is set per person. The number of shows per month varies. I would like to calculate the number of shows each person plays per month.
Best regards, Jack

J
jackheitzer@gmail.com author 4/24/2018

I managed to figure out what to do.
Thanks everyone!
Jack

P
PaulM 4/24/2018



I managed to figure out what to do.
Thanks everyone!
Jack


What did you do?