(在下面编辑以回应答案)
假设我有一个没有主键或任何其他约束的表 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 执行此查询是否有效?