I am following this tutorial: http://www.postgresqltutorial.com/postgresql-window-function/
I'm looking for a case that is not described in the tutorial and I don't found a solution.
At one moment on the tutorial, this SELECT query is used to display the products grouped by group name and their prices sorted ascending in each group, here is the result :
the request is :
SELECT
product_name,
group_name,
price,
ROW_NUMBER () OVER (
PARTITION BY group_name
ORDER BY
price
)
FROM
products
INNER JOIN product_groups USING (group_id);
I would like to sort the rows by price like in the example AND to sort the partition by descending alphabetical order, like this :
How can modify the request to obtain this result ?


ORDER BYcan be followed by a comma-separated list of sort_expressions. UseASCorDESCto set the sort direction for each expression.ASC(ascending order) is the default sort direction.Thus, you could use
ORDER BY group_name DESC, price:yields