Я объединил 13 таблиц и дал общие столбцы, но получаю повторяющиеся значения. Ниже приведен код, который я пытаюсь выполнить. Я создал временные таблицы и объединил их с существующими таблицами. Что-нибудь отсутствует в этом запросе, что приводит к дублированию значений?
SELECT
a.name,
b.to_name
--,similarity(a.name, b.to_name) conf
,b.to_email,
--c.location_id ,
--a.source ,
--b.rating_id,
-- d.record_id ,
--a.rating ,
--a.ratedtimestamp,
-- c.created_date ,
-- format_timestamp("%Y-%m-%d",h.transaction_date) as date_txn,
-- r.make,
-- s.model,
-- q.year,
-- i.transaction_type as type_txn,
-- p.vin,
-- j.associate_id,
-- l.customer_id,
-- g.transaction_id
FROM comments c
left join review_data rd on c.id = rd.id
left join r4e_mongo.mongo_repbiz_rating a on rd.rating_id = a.id
LEFT JOIN r4e_mongo.mongo_repbiz_request_reviews b on a.request_review_id=b.id
--LEFT join rep-ds-us.salesforce_b2b.forms d on cast(b.tenant_id as string)=d.tenant_id
--left join transaction_id g on c.id = g.id
--left join transaction_date h on c.id = h.id
--left join transaction_type i on c.id = i.id
--left join associate_id j on c.id = j.id
--left join customer_id l on c.id = l.id
--left join vin p on c.id = p.id
--left join year q on c.id = q.id
--left join make r on c.id = r.id
--left join model s on c.id = s.id
-- where c.tenant_id = 18
-- and c.is_removed = false
-- and a.source not in ('KIOSK','SURVEY')
where b.rating_id is not null
--group by name,to_name
order by name