Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: window函数怎么写多个?
Can multiple windows be written in this syntax where multiple rankings appear in one result?
select * from fund_order WINDOW w AS (partition by user_name order by amount desc)
No, I don’t understand. With your approach, the data can only be displayed in one order at a time. Or do you mean this kind of SQL?
SELECT earnmonth AS Month, AREA AS Region, sname AS Worker, personincome AS Income,
rank() OVER (PARTITION BY earnmonth, AREA ORDER BY personincome DESC) AS AscendingRank,
rank() OVER (PARTITION BY earnmonth, AREA ORDER BY personincome ASC) AS DescendingRank
FROM earnings;
Thank you for supporting this syntax!
Although it cannot rank simultaneously, it can globally analyze the rankings of different subjects for a particular student.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.