どのように大文字と小文字を区別してフィルタリングしますか?T-Sqlケースでフィルタリングする方法
select * from address
where streetnum > 1000 only when state = MI otherwise select everything else
または
select * from address
where case when state = MI then streetnum > 1000
どのように大文字と小文字を区別してフィルタリングしますか?T-Sqlケースでフィルタリングする方法
select * from address
where streetnum > 1000 only when state = MI otherwise select everything else
または
select * from address
where case when state = MI then streetnum > 1000
...
select * from address
where state <> 'MI' or (state = 'MI' and streetnum > 1000)
がaddress
からすべての行を取得しますが、state
が'MI'
あるときにstreetnum
が1000
よりも大きくなければなりません。
select * from address
where streetnum > 1000 or state <> 'MI'
case
を使用する場合は、チェックする値が複数ある可能性があります。
select *
from address
where case state
when 'MI' then 1000
when 'MA' then 1000
else 0
end < streetnum
これは、すべての州で同じ値(1000)を使用した場合と同じです。私は正しく、あなたの質問を解釈した場合
select *
from address
where streetnum > 1000 or state not in ('MI', 'MA')
プラスワン。 –
嫌い質問に正しく解釈するつもり嫌いLOL –