2013-04-15 31 views
2

我需要將此查詢放入SSRS報告中。將乘以行的結果集放入SSRS報告中

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得到的預期總行數。

結果集:

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 

我需要返工查詢或者可以這樣對事物的SSRS到底做了什麼?

回答

2

是的,你可以通過添加表矩陣實現這一點:

image1

,並使用相鄰的3個組(每個場分組)喜歡如下:

image2

您將獲得本結果:

image3

+1

這是一個很好的解決方案,唯一的問題是如果他有一個以上的'SR_RecID',我認爲是這種情況。因爲您需要將'SR_RecID'作爲外部組,並且可以添加'Description'和'Notes' – eestein

+0

是的,在這種情況下您是正確的,但在輸出格式的問題時刻對我來說並不完全清楚。 –

+0

這工作很好。非常感謝!記錄它是多個SR_RecIDs,所以我創建了外部組。 – Jason