如果至少有一条记录的值为1,则返回“是”
16lz
2021-01-22
I have a table in SQL Server that contains a column yesno
.
我在SQL Server中有一个包含列yesno的表。
If at least one of the rows has the column yesno=1
then I need to return only one row yes.
如果至少有一行有yesno = 1列,那么我只需返回一行yes。
I made a query that returns for every row if is yes or no.
我做了一个查询,如果是或否则返回每一行。
(select (case when isnull(coalesce(dl.yesno,'2'),'2')='1' then 'Yes' else 'NO' END)
from table dl where dl.ID='A5454322-C239-4FF2-A458-8A9BD79C1839')
3 个解决方案
#1
1
select 'yes'
where exists (select 1 from the_table where yesno = '1');
SQLfiddle example: http://sqlfiddle.com/#!3/069204/1
SQLfiddle示例:http://sqlfiddle.com/#!3/069204/1
更多相关文章
- sqlserver 差异备份与还原示例
- sqlmap遇到url重写的示例
- AppScan安全问题解决方案
- PLSQL乱码解决方案
- 数据库不支持中文解决方案(mysql)
- Mysql替代解决方案Cassandra
- [置顶] Android屏幕适配解决方案
- 物流货运移动APP解决方案
- 【java开发系列】—— struts2简单入门示例