找到匹配项时返回默认值

时间:2013-07-15 15:59:22

标签: sql

我想返回所有记录(entryID)以及选择语言标志的位置,我想返回Yes而不是attributevalue字段中的实际值。我已经尝试了这个,但是它返回的是填充的实际值,而不是找到匹配的是。我认为我需要存在的地方,因为这会为与entryID相关联的每种语言返回太多行。

SELECT distinct x.entryID, ISNOTNULL(a.attributeValue, 'Yes')
from Entry as x
left outer join EntryAttribute as e on e.entryID = x.entryID
left outer join AttributeString as a on a.AttributeID = e.AttributeID 
where a.AttributeDefinitionID = 44 

1 个答案:

答案 0 :(得分:1)

使用CASE语句。例如:

CASE WHEN attributeValue IS NOT NULL THEN 'YES' ELSE 'NO' END
相关问题