我正在使用 SSMS 2008 R2 并试图找出 SQL 选择语句来选择找到两个或多个值的所有记录。
这些是我正在寻找的四个可能的值。如果满足两个或多个这些值(SubstanceAbuse、BehaviorEmotion、SexualAbuse、DomesticViolence),我想将一个新字段设置为 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,