我正在使用SSMS 2008 R2,并试图找出SQL select语句来选择找到两个或更多值的所有记录。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,
感谢Biggs这就是它! – salvationishere 2012-04-11 18:44:37