WHERE BETWEEN
で aを実行しようとしていますCASE WHEN
:
SET @Qtr1 = datepart(MONTH,@dt1)
select
SUM(QtyInvoiced) as QtrCase
,CustName
,Town
,Rep
from SalesSumNew
where
FinMonth between
case when @Qtr1 between '1' and '3' THEN '10' and '12'
,case when @Qtr1 between '4' and '6' THEN '1' and '3'
,case when @Qtr1 between '7' and '9' THEN '4' and '6'
,case when @Qtr1 between '10' and '12' THEN '7' and '9'
end
group by CustName, Town, Rep
order by Town
エラーが発生します:
メッセージ 156、レベル 15、状態 1、行 57
キーワード「and」付近の構文が正しくありません。