0

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?

Community
  • 1
  • 1
Kira
  • 1,153
  • 4
  • 28
  • 63

1 Answers1

1

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 
M22an
  • 1,242
  • 1
  • 18
  • 35
  • thanks but this is not what I want, pleae see the SO question I mentioned – Kira Mar 28 '14 at 14:08
  • Yes you can use that logic, but you can simply use a `Full outer join` for this like, `select * from OutlookEmailsPerDay emails full outer join OutlookAttachmentsPerDay attachments on emails.DateProd = attachments.DateProd` , this way you can get all the records from both the tables irrespective of the field in ON clause – M22an Mar 29 '14 at 17:54