Join the Contacts Table to Deals

JOINing one table to another works off of unique values between the two. So, because the Deals module (in CRM) contains a lookup to the Contacts module, we can connect the two.

In Analytics, the “Contact Name” field on the Deals table is actually the 19-digit, unique Zoho ID for a Contacts record. Thus, the “Contact Name” value in the Deals module can be mapped to a specific “Id” field in the Contacts table.

To that end, the code runs like this:

FROM "Deals" 

JOIN "Contacts" ON "Id" = "Contact Name"

Then, we can, in the SELECT section of the sub-query, add in fields from the Contacts table, like the actual Contact Name and the Lead Source

However, in the next video, we’ll see that we need to add table aliases to our code.

See the full code if needed