Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Oracle 中,以下三个查询中哪个最有效:
SELECT DISTINCT a, b FROM tab
SELECT a, b FROM tab GROUP BY a, b
SELECT a, b FROM (SELECT a, b, row_number() OVER (PARTITION BY a, b ORDER BY a, b) rn FROM tab ) WHERE rn = 1
第一个是正确的选择,因为其他是实现相同目标的古怪和非标准(并且有点反常)的方式。