POSTGRESQL is showing "ERROR: syntax error at or near "DISTINCT"

POSTGRESQL is showing "ERROR: syntax error at or near "DISTINCT"

我尝试在列名后使用 DISTINCT 关键字,但它给出了语法 error.At,同时在 DISTINCT 关键字获取 result.Can 后写了相同的列名,请告诉我这是为什么那么?

图像:DISTINCT keyword after a column name

图像:column name after DISTINCT keyword

DISTINCT应用于输出结果,需要跟在SELECT之后,不能在个别列上调用。 GROUP BY 可以为您提供单列结果,如果您正在寻找的话。

-- filter all results
SELECT DISTINCT film_id, rental_rate FROM film;

-- filter on rental_rate
SELECT film_id, rental_rate FROM film GROUP BY rental_rate;

-- syntax error
SELECT film_id, DISTINCT(rental_rate) FROM film;