我嘗試加入3個表是這樣的:加入與查詢SQL 3個表
表1:國家
Id | Country
-------------------
1 | UK
2 | USA
3 | France
表2:日期
Id | Date
-----------------
20000101 | 2000-01-01
20000102 | 2000-01-02
...
20140901 | 2014-09-01
表3:客戶
Id | Customer | Date_Creation_Id | Country_Id
---------------------------------------------
1 | AAA | 20000102 | 1
2 | B | 20000102 | 2
2 | CC | 20000103 | 2
我想找到nu所有日期和所有國家的新客戶。
Date | Country | number of creation
-------------------------------------------------
20000101 | UK | 0
20000101 | USA | 0
20000101 | France | 0
20000102 | UK | 1
20000102 | USA | 2
20000102 | France | 0
20000103 | UK | 0
20000103 | USA | 1
20000103 | France | 0
我嘗試此查詢
select count(*) as count,Customer.Date_Creation_Id, Customer.Country_Id
from customer
Right join Date on Dates.Id = Customer.Date_Creation_Id
Right join Country on Country.Id = Customer.Country_Id
group by Customer.Date_Creation_Id, Customer.Country_Id
但我不知道所有日期與它