简体   繁体   English

选择带有where子句的查询并在ms访问查询中分组

[英]select query with where clause and group by in ms access query

I'm having table which contains columns Id and Pcode. 我有包含ID和Pcode列的表。 where ID column is foreign key. 其中ID列是外键。 I'm trying to get the ID, which Pcode does not contains the value 'FT' with group by 'ID'. 我正在尝试获取ID,其中Pcode不包含带有“ ID”分组的值“ FT”。

Sample Data: 样本数据:

在此处输入图片说明

Desired Result: 所需结果:

ID ID

3 3

the desired result is 3. the ID column 3 does not have the Pcode FT. 期望的结果是3。ID列3没有Pcode FT。 Can anyone help me to write a query to get the desired result. 任何人都可以帮助我编写查询以获取所需的结果。 Thanks in Advance. 提前致谢。

One option would be to use aggregation: 一种选择是使用聚合:

SELECT ID
FROM yourTable
GROUP BY ID
HAVING SUM(IIF(PCODE = 'FA', 1, 0)) = 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM