我有兩個表用戶和任務。我需要獲得由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 -|