私は SSMS 2008 R2 を使用しており、2 つ以上の値が見つかったすべてのレコードを選択する SQL 選択ステートメントを見つけようとしています。
これらは、私が探している 4 つの可能な値です。これらの値 (SubstanceAbuse、BehaviorEmotion、SexualAbuse、DomesticViolence) の 2 つ以上が満たされた場合、新しいフィールドを 1 に設定したいと考えています。どうすればよいですか?
case when qav.[test_setup_details_caption] in ('Substance Abuse / Drug Use','Caregiver monitor youth for drug alcohol use') then 1 else 0 end SubstanceAbuse,
case when qav.[test_setup_details_caption] in ('Physical Aggression','Firesetting','Gang Involvement','Runaway Behavior') then 1 else 0 end BehaviorEmotion,
case when qav.[test_setup_details_caption] = 'Problem Sexual Behavior' then 1 else 0 end SexualAbuse,
case when qav.[test_setup_details_caption] LIKE '%Domestic%' then 1 else 0 end DomesticViolence,