计算表中两组不同的行,然后将它们分开

时间:2012-02-10 04:24:06

标签: mysql sql

我是MySQL的新手,我正在尝试提出一个基本上做的查询:

select * from tasks where completed = 1;

除以......

select * from tasks where completed = 0; 

我已经搜索过这个解决方案但是只找到了平均两个表或行之间的实际值的方法,但是没有计算行项目的数量。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:2)

这应该有效:

select
    (select count(*) from tasks where completed = 1) /
    (select count(*) from tasks where completed = 0)
from dual