ГОСПОДИН ПАЛИСИЯ
Мастер
(1544)
1 год назад
Чтобы переименовать колонку "dense_rank" в "column_4", необходимо заменить строку
sql
Copy code
dense_rank() over (partition by p.customer_id order by amount desc)
на
sql
Copy code
dense_rank() over (partition by p.customer_id order by amount desc) as "column_4"
Итоговый запрос будет выглядеть следующим образом:
sql
Copy code
SELECT
customer_id,
payment_id,
payment_date,
row_number() over (order by payment_date) as "column_1",
row_number() over (partition by customer_id order by payment_date) as "column_2",
sum(p.amount) over (partition by p.customer_id order by p.payment_date) as "column_3",
dense_rank() over (partition by p.customer_id order by amount desc) as "column_4"
FROM payment p
order by customer_id, column_4
customer_id,
payment_id,
payment_date,
row_number() over (order by payment_date) as "column_1",
row_number() over (partition by customer_id order by payment_date) as "column_2",
sum(p.amount) over (partition by p.customer_id order by p.payment_date) as "column_3",
dense_rank() over (partition by p.customer_id order by amount desc)
FROM payment p
order by customer_id, dense_rank