実現したいこと
SQL Serverにおいて、where句にcase whenを使いたいです。
(例)
select
hoge
from
temp1
where
col1=1
and
case when
col2=2 then col3=3 and col4=4
case when
col5=5 then col6=6 and col7=7
end
発生している問題・分からないこと
then 後の最初の=のところで、「'=' 付近に不適切な構文があります」のエラーがでます。
エラーメッセージ
error
1'=' 付近に不適切な構文があります。 2
該当のソースコード
SQL
1select 2 hoge 3from 4 temp1 5where 6 col1=1 7 and 8 case when 9 col2=2 then col3=3 and col4=4 10 case when 11 col5=5 then col6=6 and col7=7 12end
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
同様の試みが見つかりませんでした。
補足
特になし
