我有一個表,這個數據:動態列
FirstDiscovered|LastDiscovered|Application|Computer|Organisation
----------------------------------------------------------------
05.03.2017 |05.08.2017 |App A |Comp 1 |Org 1
----------------------------------------------------------------
04.13.2017 |08.01.2017 |App A |Comp 2 |Org 1
----------------------------------------------------------------
05.01.2017 |08.01.2017 |App B |Comp 2 |Org 1
----------------------------------------------------------------
06.13.2017 |08.02.2017 |App A |Comp 3 |Org 2
----------------------------------------------------------------
07.14.2017 |08.02.2017 |App A |Comp 4 |Org 2
----------------------------------------------------------------
07.14.2017 |08.02.2017 |App B |Comp 3 |Org 2
----------------------------------------------------------------
我想與基於日期屬性「firstDiscovered」和「lastDiscovered」 select語句中的動態列延伸。 假設有一行firstDiscovered = 05.27.17和lastDiscovered = 06.25.17。那麼我預計5月17日和6月17日會有兩個新專欄填入「1」。通過設置爲「0」或空的其他行產生的所有其他列(個月),見例如:
FirstDiscovered|LastDiscovered|Application|Computer|Organisation|Apr 17|May 17|Jun 17|Jul 17|Aug 17
---------------------------------------------------------------------------------------------------
05.03.2017 |05.08.2017 |App A |Comp 1 |Org 1 |0 |1 |0 |0 |0
---------------------------------------------------------------------------------------------------
04.13.2017 |08.01.2017 |App A |Comp 2 |Org 1 |1 |1 |1 |1 |1
---------------------------------------------------------------------------------------------------
05.01.2017 |08.02.2017 |App B |Comp 2 |Org 1 |0 |1 |1 |1 |1
---------------------------------------------------------------------------------------------------
06.13.2017 |08.02.2017 |App A |Comp 3 |Org 2 |0 |0 |1 |1 |1
---------------------------------------------------------------------------------------------------
07.14.2017 |08.02.2017 |App A |Comp 4 |Org 2 |0 |0 |0 |1 |1
---------------------------------------------------------------------------------------------------
07.18.2017 |08.02.2017 |App B |Comp 3 |Org 2 |0 |0 |0 |1 |1
---------------------------------------------------------------------------------------------------
將是巨大的,如果有人能幫助我。
有關使用CASE什麼基於表達式添加「動態」列? – mauro
我的猜測你想要這個動態添加開始月份和結束月份之間的所有列,並使其動態?這是可行的,但在SSRS的交叉標籤報告中更容易。 – KeithL
必須是選擇語句。無法使用SSRS –