Kira
Kira

Reputation: 1207

Combine multiple tables with different date values

As the title indicates, I want to create a view that combines multiple tables with different dates. The tables are as follow : (examples)

OutlookEmailsPerDay :

enter image description here

OutlookAttachmentsPerDay :

enter image description here

OutlookSyncPerDay :

enter image description here

OutlookSentEmailsPerDay :

enter image description here

Based on the ComputerSystemId, I want to join those tables to get a result similar to the one in this question : SQL - Combine two tables with different date value Does the same approach work for more than two tables. I know I can combine two tables then add another and so on, but is it possible to do it in one step?

Upvotes: 0

Views: 92

Answers (1)

M22an
M22an

Reputation: 1292

Try this,

select *
from OutlookEmailsPerDay emails
inner join OutlookAttachmentsPerDay attachments on emails.ComputerSystemId = attachments.ComputerSystemId
inner join OutlookSyncPerDay sync on emails.ComputerSystemId = sync.ComputerSystemId 
inner join OutlookSentEmailsPerDay sent on sent.ComputerSystemId  = emails.ComputerSystemId 

Upvotes: 1

Related Questions