Coding task · SQL and MySQL course · Module 10: Transactions and advanced SQL

A CTE with a ranking

Combine a CTE with a window function: first compute the numbers, then retrieve the result. This is an advanced Keeper's query.

Task

Write a CTE named ranking that selects tytul, cena and ROW_NUMBER() OVER (ORDER BY cena DESC) AS numer from the ksiazki table. Then, in the main query, retrieve all columns from ranking. Use the syntax WITH ranking AS (SELECT ...) SELECT * FROM ranking;