我正在用 SQL 编写一个用于 SSRS 2005 的查询,它是
select t1.Category, t2.condition,'1' as hasCondition from t1
left outer join t2 on t1.ID = t2.ID
left outer join t3 on t2.cID = t3.cID
where t3.clientID = 6
union
select t1.Category, t2.condition, '0' as hasCondition from t1
left outer join t2 on t1.ID = t2.ID
并将数据返回为:
Category Condition hasCondition
Behavioural Tourette's Syndrome 0
Communications Impaired Speech 0
Dexterity Osteoarthritus 0
Dexterity Osteoporosis 0
Dexterity Other Dexterity 0
Dexterity Rheumatoid Arthritus 0
Emotional Bipolar Disorder 0
Emotional Clinical Depression 0
Emotional Depression 0
Emotional Depression 1
Emotional Gulf War Syndrome 0
Emotional Gulf War Syndrome 1
现在我只想从重复行/结果中选择一条记录,例如:Category-Emotional, condition-Depression which hasCondition '1' or 'true'
我希望我用这个例子说清楚了。请帮我。
谢谢。