0
SELECT s.SR_Service_RecID -- will have 1 result
, p.Description -- will have 8 results
, t.notes -- will have 5 results
FROM SR_Service s
LEFT JOIN IV_Product p
ON p.SR_Service_RecID = s.SR_Service_RecID
LEFT JOIN Time_Entry t
ON t.SR_Service_RecID = s.SR_Service_RecID
該查詢將p.Description乘以t.Notes獲得的總行數。每個p.Description對每個單獨的t.notes顯示5次。行數乘以結果數
結果集:
SR_RecID Description Notes
12345 Product 1 Note 1
12345 Product 1 Note 2
12345 Product 1 Note 3
12345 Product 1 Note 4
12345 Product 1 Note 5
12345 Product 2 Note 1
12345 Product 2 Note 2
12345 Product 2 Note 3
12345 Product 2 Note 4
12345 Product 2 Note 5
Etc..
我不能確定如何解決這一個...任何幫助,將不勝感激。
[編輯]: 由於結果是正確的,您如何才能將此信息放入SSRS報告中以顯示正確數量的結果,因爲它將顯示所有重複的行?
SR_RecID
12345
Description
Product 1
Product 2
Product 3
Product 4
Product 5
Product 6
Product 7
Product 8
Notes 1
Notes 2
Notes 3
Notes 4
Notes 5
查詢工作正常,你想要什麼? – 2013-03-21 05:19:04
這就是你的查詢應該做的事情,你想要什麼?主要結果? – ljh 2013-03-21 05:31:13
顯然,對於每個'SR_RecID'都有幾個產品和幾個筆記 - 那麼你到底想要什麼?您的查詢輸出看起來像我期待的結果... – 2013-03-21 05:41:27