要对 PostgreSQL 中的数据进行去重排序,可以使用以下方法:
SELECT DISTINCT column1, column2
FROM table_name
ORDER BY column1, column2;
SELECT column1, column2
FROM (
SELECT column1, column2, ROW_NUMBER() OVER (PARTITION BY column1, column2 ORDER BY column1, column2) AS rn
FROM table_name
) sub
WHERE rn = 1
ORDER BY column1, column2;
这样可以按照指定的列进行排序,并去除重复值。