我有两张桌子:
Travellers_Report
Name Country Place_of_visit Return_date
A United States Los Angeles 2/27/2013
B United Arab Emirates DUBAI 2/21/2013
C Puerto Rico San Juan 2/28/2013
D United States Los Angeles 2/27/2013
E United States Boston 2/27/2013
F Malaysia Kulalampur 3/1/2013
G United Arab Emirates DUBAI 2/15/2013
H Malaysia Kulalampur 3/15/2013
I United States Los Angeles 2/27/2013
公司_存在
Country City
United States Los Angeles
United Arab Emirates DUBAI
United States Boston
我需要将“Travellers_Report”表的“Place_of_visit”字段与“Company_presence”表的“City 字段”进行比较并获取计数。
预期输出为:
Country Place_of_visit Count
United States Los Angeles 3
United Arab Emirates DUBAI 2
United States Boston 1
截至目前,我在下面有两个查询,但我不知道如何将它们组合起来以获得预期的结果。
sqlstr = "SELECT * " & _
"FROM Travellers_report " & _
"WHERE Travellers_report.Return_Date >= #" & DOI & "# AND
Travellers_report.Return_Date <=#" & tempd & "#;"
和
SELECT Travellers_report.Place_of_Visit, count(1) FROM Travellers_report
GROUP BY Place_of_Visit