Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 当我们按列(C1)分组时,选择列(C2)中缺少特定值(V1)的特定列(C1)_Sql_Postgresql - Fatal编程技术网

Sql 当我们按列(C1)分组时,选择列(C2)中缺少特定值(V1)的特定列(C1)

Sql 当我们按列(C1)分组时,选择列(C2)中缺少特定值(V1)的特定列(C1),sql,postgresql,Sql,Postgresql,我有一个postgres表,如下所示: C1 C2 ------------------------------------- apple No Thorns apple No Thorns orange Thorns apple No Thorns pineapple

我有一个postgres表,如下所示:

C1                          C2     
-------------------------------------
apple                      No Thorns
apple                      No Thorns
orange                     Thorns
apple                      No Thorns
pineapple                  No Thorns
pineapple                  Thorns
guava                      No Thorns
guava                      Thorns
现在,我想要在一次查询中从未在C2中找到刺的那些水果的名称C1。 如果这件事很琐碎,我会提前道歉


以上问题的答案是苹果公司

我将通过以下方式使用该小组:

我会试试看

Select distinct c1 from table1
Where not exists (
Select 1 from table1  t2 where table1.c1 = t2.c1 and t2.c2 = 'Thorns')
Select distinct c1 from table1
Where not exists (
Select 1 from table1  t2 where table1.c1 = t2.c1 and t2.c2 = 'Thorns')