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
答案 0 :(得分:0)
如果通过“解析”表示如何只为每个SR_RecID
和Description
添加1个音符,那么您需要使用聚合函数({{{{{{ {1}},Notes
等)。
否则,多次评论,您的结果是预期的结果。