在多个国家中,从其连接的商店中没有>0雇用值的公司列表中,我希望检索在有就业的国家以外的国家中具有空就业值的in。在下面的例子中,我只想检索id A。这是一个oracle数据库。
表结构
公司
| id | store | country| employment
---------------------------------
|A | 1 | US | 0 |
---------------------------------
|A | 2 | US | 9 |
---------------------------------
|A | 3 | DE | null |
---------------------------------
|B | 4 | US | 0 |
---------------------------------
|B | 5 | DE | null |
---------------------------------
|B | 6 | DE | 4 |
---------------------------------
|B | 7 | DE | 4 |
---------------------------------
*原谅我,我不知道如何在问题中以更好的格式呈现表格结构。
发布于 2018-07-20 11:32:37
这是你想要的吗?
select distinct id
from company c
group by id, country
having count(employment) <> count(*) and -- there is at least one NULL value
count(employment) > 0 ; -- there is at least one not NULL value
https://stackoverflow.com/questions/51441540
复制相似问题