0

(在下面编辑以回应答案)

假设我有一个没有主键或任何其他约束的表 R(a,b)。

dmg@[local] test1=# table R;
 a | b  
---+----
 1 | 10
 1 | 20
 2 | 30
 2 | 10
(4 rows)

查询 

select a,b 
from R group a ;

在 Postgresql 中无效(如果 a 是 R 的主键就可以了)。

dmg@[local] test1=# select a,b from R group by a;
ERROR:  column "r.b" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: select a,b from R group by a;
             ^

但在 sqlite3 中是允许的。它从每个子集中的元组中选择 b 的值(非确定性地)。

sqlite> select a,b from R group by a;
a           b         
----------  ----------
1           10        
2           30 

oracle 执行此查询是否有效?

4

1 回答 1

1

首先,它不再被 MySQL 接受。

其次,它不返回“随机”值。它从不确定的行返回一个值。

第三,它违反了SQL标准。

最后,Oracle 不支持这种语法。

于 2021-06-17T18:11:15.233 回答