Возникли проблемы при написании соединений sql.Я объединяю три таблицы, чтобы определить количество.
Таблица 1 - EmmaResponseOpens
[storecode]
[firstname]
[lastname]
[px_or_ot_joindate]
[datelastdined]
[pxcardnumber]
[birthdate]
[fishbowl_join_date]
[ot_signup]
[last_input_source]
[timestamp]
[member_id]
[member_since]
[email_domain]
[email_user]
[email]
[member_status_id]
[mailing_id]
Таблица 2 - EmmaCustomer
[Status]
[Confirmed_Opt_In]
[Account_ID]
[StoreCode]
[FirstName]
[LastName]
[Eclub_Member]
[Email_Number]
[Eclub]
[Last_Input_Source]
[Fishbowl_Join_Date]
[Px_Or_Ot_Joindate]
[Ot_Signup]
[Member_ID]
[Last_Modified_At]
[Member_Status_ID]
[Plaintext_Preferred]
[Email_Error]
[Member_Since]
[Bounce_Count]
[Deleted_At]
[Email]
[pxCardNumber]
[Member_Group_ID]
[Preferred_Location_Henrys]
[Preferred_Location_Palomino]
[Preferred_Location_Kincaids]
[Preferred_Location_Psc]
[Preferred_Location_Stanfords]
[portland_or]
[bellevue_wa]
[plano_tx]
[denver_co]
[pdx_airport_or]
[seattle_wa]
[st_paul]
[oakland]
[bloomington]
[redondo_beach]
[burlingame]
[bellevue]
[seattle]
[los_angeles]
[indianapolis]
[san_francisco]
[tigard]
[portland_washington]
[walnut_creek]
[portland_066]
[portland_082]
[hillsboro]
[lake_oswego]
[clackamas]
[tukwila]
Таблица 3 -EmmaGroups
[active_count]
[deleted_at]
[error_count]
[optout_count]
[group_type]
[member_group_id]
[purged_at]
[account_id]
[group_name]
[date_time]
Запрос:
SELECT DISTINCT COUNT(Email)
FROM MyEmma.dbo.EmmaResponseOpens t1
INNER JOIN EmmaCustomer t2
ON t1.member_id = t2.member_id
INNER JOIN Groups t3
ON t3.member_group_id = t2.member_group_id
Я ожидаю, что будет возвращено то, что не совпадает в EmmaResponseOpens
и EmmaCustomers
(с использованием member_id
) изатем фильтруется на основе member_group_id
.