Question: Consider an SQL query that has a Window function with an ORDER BY inside the OVER clause, and an ORDER BY in the main query
Consider an SQL query that has a Window function with an ORDER BY inside the OVER clause, and an ORDER BY in the main query like this:
SELECT productid saledate, amountsold, SUMamountsold OVER PARTITION BY productid ORDER BY saledate AS totalsales
FROM sales
ORDER BY productid saledate;
Consider an SQL query that has a Window function with an ORDER BY inside the OVER clause, and an ORDER BY in the main query like this:
SELECT productid saledate, amountsold, SUMamountsold OVER PARTITION BY productid ORDER BY saledate AS totalsales
FROM sales
ORDER BY productid saledate;
The query will be illegal
The main ORDER BY will be executed first
The ORDER BY inside the OVER clause will be executed first
None of the above
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
