php - Select from 3 tables with calculating -
i try make query in mysql gets data 3 tables, , calculate in 2 tables. don't know how this.
i have in php code calculate "avage cost per click":
get campaigns.
select * campaigns;
get how many clicks campaign has:
select sum(id) ialt2 aktivitet annonce_id = '@@campaign_id' group ip");
get total revenure rows
select sum(price) ialt money ad = '@@campaign_id' group id
now can calculate "avage cost per click"
"ialt / ialt2" = cpc
then should say:
select * campaign order cpc desc limit 0,1
select * campaigns c order ( (select sum(price) money ad = c.campaign_id) / (select sum(id) aktivitet annonce_id = c.campaign_id) )desc limit 0,1
just guessing, think want this
Comments
Post a Comment