要對 PostgreSQL 中的數(shù)據(jù)進(jìn)行去重排序,可以使用以下方法:
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;
這樣可以按照指定的列進(jìn)行排序,并去除重復(fù)值。