de_notes

📚 WINDOW FUNCTION

Window functions in SQL perform calculations across a set of table rows that are related to the current row.
Unlike aggregate functions, they do not collapse the result set.


🛠️ Basic Syntax

SELECT column1, 
       window_function() OVER (PARTITION BY column2 ORDER BY column3)
FROM table_name;

Example

SELECT employee_id, department_id, salary,
       RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS salary_rank
FROM employees;

Key Points

Additional Example

SELECT order_id, customer_id, 
       ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date) AS order_sequence
FROM orders;

🎥 Video Notes


📝 Problem Description

Describe the problem, challenge, or topic discussed in a video related to SELECT FROM.
What concept was explained or what exercise was solved?


DataBase Given


💻 My SQL Code

-- Write your SQL code attempt or solution related to SQL COMMAND
SQL COMMAND

🧠 Solution Code / Explanation

SQL COMMAND

Explanation - Explain what you learned, any key takeaways, or how you solved the problem related to COMMAND._


⬅️ Previous: SUBQUERY IN CONDITION Next ➡️ ROW NUMBER