I'm trying to get 2 counts from 2 tables and work out the percentage like for a MySQL db:
select field_one, count(*) as COUNT_ONE from table1 group by field_one;
select other_field,count(*) as COUNT_TWO from table2 group by other_field;
I want to combine the results and have FINAL_COUNT=(COUNT_ONE/COUNT_TWO) * 100
for percentage ?
quick and dirty:
select (a.count_one / b.count_two) * 100 as final_count from
(select field_one, count(*) as count_one from table1 group by field_one) a,
(select field_two, count(*) as count_two from table2 group by field_two) b
where a.field_one = b.field_two
select sum(((QUERY FROM TABLE 1) / (QUERY FROM TABLE 2)) * 100) as percentage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With