3
我很新的MySQL和我試圖想出一個查詢,基本上沒有:獲得兩套不同行的總數在一個表,然後將它們
select * from tasks where completed = 1;
除以...
select * from tasks where completed = 0;
我已經搜索了一個解決方案,但只找到方法來平均兩個表或行之間的實際值,但不計算行項目。任何幫助將不勝感激!
我很新的MySQL和我試圖想出一個查詢,基本上沒有:獲得兩套不同行的總數在一個表,然後將它們
select * from tasks where completed = 1;
除以...
select * from tasks where completed = 0;
我已經搜索了一個解決方案,但只找到方法來平均兩個表或行之間的實際值,但不計算行項目。任何幫助將不勝感激!
這應該工作:
select
(select count(*) from tasks where completed = 1)/
(select count(*) from tasks where completed = 0)
from dual
這正是我一直在尋找!謝謝!! – 2012-02-10 04:36:35