SQL Server中的大小写运算符 [英] case operator in sql server
本文介绍了SQL Server中的大小写运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果名字列为空,那么我必须使用case运算符显示另一个列值.
if firstname column is null then i have to display a another column value using case operator
推荐答案
尝试以下查询
Try following query
select (case when column1 is null then column2 else column1 end) columnname from [tablename]
谢谢
检查此 http://www.devx.com/tips/Tip/15633 [ ^ ]
希望对您有所帮助
Check this http://www.devx.com/tips/Tip/15633[^]
Hope it will help
Simple CASE expression:
CASE input_expression
WHEN when_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END
Searched CASE expression:
CASE
WHEN Boolean_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END
这篇关于SQL Server中的大小写运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文