1
我有兩個管理員和客戶的表。 因此「客戶」表具有以下字段:如何在附加條件下添加相同的色譜柱?
1. id_client
2. email
3. name
4. id_manager
5. made_a_deal (bool field)
而「經理」表具有以下字段:
1. id_manager
2. name
這兩個表由id_manager鍵連接。
我想獲得一個表,其中顯示以下字段:
1. id_manager
2. managers.name
3. COUNT(By field id_client)
And I couldn't make the fourth filed:
4. COUNT(By field id_client, which have bought something ('client.made_a_deal' is true))
我的代碼是:
USE database_name;
SELECT
managers.id_manager,
managers.name,
COUNT(client.id_client) AS `all`
FROM managers
LEFT OUTER JOIN
client
ON
managers.id_manager = client.id_manager
GROUP BY managers.name
;
我應該如何修改我的代碼,以達到所需的表?
很酷!這是非常簡單和天才的解決方案!謝謝! –