我有两个表用户和任务。我需要获得由Users.Name和Tasks.Status分组的任务数。我需要一些帮助来编写查询,以使我的结果看起来类似于第三个表。SQL查询:由不同表中的多列组成
用户
|- Id -|- Name -|
|- 1 -|- Robert -|
|- 2 -|- Bob -|
|- 3 -|- Vicky -|
|- 4 -|- Don -|
|- 5 -|- Ron -|
|- 6 -|- Harry -|
任务
|- Id -|- Status -|- user_id -|
|- 1 -|- Started -|- 1 -|
|- 2 -|- Started -|- 1 -|
|- 3 -|- Started -|- 2 -|
|- 4 -|- Started -|- 2 -|
|- 3 -|- Complete -|- 1 -|
|- 4 -|- Complete -|- 1 -|
|- 5 -|- Complete -|- 2 -|
|- 6 -|- Complete -|- 2 -|
结果
|- Name -|- Status -|- Count -|
|- Robert -|- Complete -|- 2 -|
|- Robert -|- Started -|- 2 -|
|- Bob -|- Complete -|- 2 -|
|- Bob -|- Started -|- 2 -|
|- Vicky -|- Complete -|- 0 -|
|- Vicky -|- Started -|- 0 -|
|- Don -|- Complete -|- 0 -|
|- Don -|- Started -|- 0 -|
|- Ron -|- Complete -|- 0 -|
|- Ron -|- Started -|- 0 -|
|- Harry -|- Complete -|- 0 -|
|- Harry -|- Started -|- 0 -|