Postgres 中带有 DENSE_RANK FIRST ORDER BY 的 Oracle 语句
Oracle Statement with DENSE_RANK FIRST ORDER BY in Postgres
有人能告诉我如何在 Postgres SQL 中转换以下 Oracle SQL 语句吗?没看懂...
SELECT MIN(t2.id) KEEP (DENSE_RANK FIRST ORDER BY t2.edit_date) AS id
FROM temp t2
GROUP BY t2.sku
SELECT MIN(t2.id) OVER (ORDER BY t2.edit_date) AS id
FROM temp t2
GROUP BY t2.sku
编辑:
尽管上面做了 OP 的要求,但给定查询的等效项可以是:
select min(t.id) id
from
(select t.*,
dense_rank() over (order by t.edit_date) AS rnk
from temp t) t
where rnk = 1
group by t.sku;
有人能告诉我如何在 Postgres SQL 中转换以下 Oracle SQL 语句吗?没看懂...
SELECT MIN(t2.id) KEEP (DENSE_RANK FIRST ORDER BY t2.edit_date) AS id
FROM temp t2
GROUP BY t2.sku
SELECT MIN(t2.id) OVER (ORDER BY t2.edit_date) AS id
FROM temp t2
GROUP BY t2.sku
编辑:
尽管上面做了 OP 的要求,但给定查询的等效项可以是:
select min(t.id) id
from
(select t.*,
dense_rank() over (order by t.edit_date) AS rnk
from temp t) t
where rnk = 1
group by t.sku;