Ser*_*gio 11 sql t-sql sql-server
我正在查询数据库,并且我需要组合2位列(对于此示例,如果一个为真,则列必须为true).
就像是: Select col1 || col2 from myTable
实现这一目标的最简单方法是什么?
Ste*_*ger 15
select col1 | col2 from myTable
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/ms176122.aspx
我假设col1和col2是位值,最接近的Sql Server必须是布尔值.
要返回1或0:
select case when col1=1 or col2=1 then 1 else 0 end
from yourtable
Run Code Online (Sandbox Code Playgroud)
要返回true或false:
select case when col1=1 or col2=1 then 'true' else 'false' end
from yourtable
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3358 次 |
最近记录: |