我有以下查詢返回一個列表:SQL服務器的選擇的情況下在聲明中
SELECT cpa_0.[Period] as "Period", cpa_0.[Account] as "Account", cpa_0.[Center] as "Center", cpa_0.[Scenario] as "Scenario", cpa_0.[Effective_Date] as "Effective_Date"
FROM [dbo].[GLDetail] cpa_0
WHERE cpa_0.[Center] = $$Centers-VALUE$$ and
cpa_0.[Account] = $$Accounts-VALUE$$ and
cpa_0.[Period] = case
when $$View-VALUE$$ = 'Periodic' then $$Periods-VALUE$$
when $$View-VALUE$$ = 'Y_T_D' then ('2017-09','2017-08')
end
的價值$$是變量過去了,他們工作得很好。我的問題是查詢的最後一行,當$$ View-VALUE $$ ='Y_T_D'then('2017-09','2017-08')時,這不起作用。當我的變量等於Y_T_D時,我需要返回一個列表,我該怎麼做?
Regards
旁註:你試圖在這裏做可能不執行,以及你所期望的。看到[這個問題](https://stackoverflow.com/questions/26919158/performance-considerations-for-conditional-queries-search-forms)和博客文章鏈接在頂部的答案。 –