我试图从2个表中得到2个计数并计算出像MySQL数据库那样的百分比:
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;
我想结合结果并FINAL_COUNT=(COUNT_ONE/COUNT_TWO) * 100保持百分比?
Fos*_*sco 17
又快又脏:
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
Run Code Online (Sandbox Code Playgroud)
select sum(((QUERY FROM TABLE 1) / (QUERY FROM TABLE 2)) * 100) as percentage
Run Code Online (Sandbox Code Playgroud)