3

I'm very new to MySQL and I'm trying to come up with a query that basically does:

select * from tasks where completed = 1;

divided by...

select * from tasks where completed = 0; 

I've searched for a solution to this but have only found ways to average actual values between two tables or rows, but by not counts of row items. Any help would be greatly appreciated!

Tim Aych
  • 1,365
  • 4
  • 16
  • 34

1 Answers1

2

This should work:

select
    (select count(*) from tasks where completed = 1) /
    (select count(*) from tasks where completed = 0)
from dual
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523