有人可以告诉我如何在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
答案 0 :(得分:-1)
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;