2014-03-28 18 views
0

正如標題所示,我希望創建一個結合了不同的日期多個表的視圖。 的表如下:(實施例)將多臺不同的日期值

OutlookEmailsPerDay:

enter image description here

OutlookAttachmentsPerDay:

enter image description here

OutlookSyncPerDay:

enter image description here

OutlookSentEmailsPerDay:

enter image description here

基礎上ComputerSystemId,我想加入這些表得到一個類似於這個問題的結果: SQL - Combine two tables with different date value 做同樣的方式工作了兩個以上的表。我知道我可以合併兩個表格,然後添加另一個表格,但是可以一步完成嗎?

回答

1

試試這個,

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 
+0

謝謝,不過這不是我想要的,pleae看到我提到 – Kira

+0

是的,你可以使用該邏輯的SO問題,但你可以簡單地使用'全外join'此就像,'選擇* 從OutlookEmailsPerDay電子郵件 全外連接OutlookAttachmentsPerDay附件上emails.DateProd = attachments.DateProd',這種方式可以從兩個表獲取所有記錄,不論該領域的ON子句 – M22an