0

I am trying to combine these queries into 1

# Get completed todos
SELECT COUNT(t.id) from Application\Models\Todos t 
WHERE t.parent IS NULL 
AND t.todoList.project = :proj
AND t.completedOn IS NOT NULL

# Get total todos
SELECT COUNT(t.id) from Application\Models\Todos t
WHERE t.parent IS NULL 
AND t.todoList.project = :proj
  • A Project have Lists
  • A List have Todos
  • A Todo can have 1 level of children todo - In my queries, I was querying for top level todos
  • A Todo have completedOn, dueOn

In another function, I want to get

  • total number of tasks belonging to you & the project
  • total number of completed tasks belonging to you & the project
  • total number of incompleted tasks due today belonging to you & the project

Do I need to do it in separate queries?

4

1 回答 1

0

如果您有一个标志 INT 以 1/0 完成,那么是的,使用 SUM 和 COUNT,但在这种情况下,我认为这是不可能的。

于 2011-01-20T15:59:57.417 回答