我是MySQL的新手,我正在尝试提出一个基本上做的查询:
select * from tasks where completed = 1;
除以......
select * from tasks where completed = 0;
我已经搜索过这个解决方案但是只找到了平均两个表或行之间的实际值的方法,但是没有计算行项目的数量。任何帮助将不胜感激!
答案 0 :(得分:2)
这应该有效:
select
(select count(*) from tasks where completed = 1) /
(select count(*) from tasks where completed = 0)
from dual