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