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
4

1 回答 1

0

如果通过“解决”您的意思是如何每个音符只有 1 个SR_RecIDDescription那么您需要Notes使用聚合函数(MAXMIN等)为每个音符仅选择 1 个。

否则,正如多次评论的那样,您的结果是预期的。

于 2013-03-21T06:20:40.740 回答