如果符合特定条件,则排除行 [英] Exclude rows if it matches certain conditions
本文介绍了如果符合特定条件,则排除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我有以下查询返回的记录。
Hello,
I have following sort of records returned from a query.
Name ===== CanAccess
--------------------------------
Payroll ===== 0
Payroll ===== 1
Employees ===== 0
Employees ===== 1
Inventory ===== 0
Finance ===== 0
如果CanAccess我想从同一个名称中选择唯一记录对于他们中的任何一个都是如此。
我希望输出像 -
I want to select unique records from same Name if "CanAccess" is true for any of them.
I want output like-
Name ===== CanAccess
--------------------------------
Payroll ===== 1
Employees ===== 1
Inventory ===== 0
Finance ===== 0
我尝试了什么:
我尝试了不同的连接,但没有运气。
What I have tried:
I tried different joins, but no luck.
推荐答案
select name from [mytablenmame] where CanAccess=1
给定OP的样本数据,其中只有两个给定名称的记录,其中每个都有CanAccess的值不同,无需聚合即可获得他声称的结果。停止对我的回答进行投票。
[/ EDIT]
Given the OP's sample data, where there are only TWO records for a given name, and EACH of them having a different value for CanAccess, aggregation is not required to get the results he claims to be after. Stop 1-voting my answer.
[/EDIT]
这篇关于如果符合特定条件,则排除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文