SOLUTION: WINDOW FUNCTION RANK() OVER() => FOR BIG DATA ( MySQL + SQL Server) 🔥🔥🔥🔥
Intuition\r\n Describe your first thoughts on how to solve this problem. \r\n\r\n# Approach\r\n Describe your approach to solving the problem. \r\n\r\n# Complex
# Intuition\r\n<!-- Describe your first thoughts on how to solve this problem. -->\r\n\r\n# Approach\r\n<!-- Describe your approach to solving the problem. -->\r\n\r\n# Complexity\r\n- Time complexity:\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\n\r\n- Space complexity:\r\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\r\n\r\n# Code\r\n```\r\n/* Write your T-SQL query statement below */\r\n\r\nWITH RESULT AS (\r\n\r\n    SELECT\r\n        s.product_id,\r\n        year,\r\n        quantity,\r\n        price,\r\n        RANK() OVER(PARTITION BY s.product_id ORDER BY s.product_id,year) AS Rank\r\n    FROM\r\n        Sales s\r\n)\r\nSELECT\r\n        product_id,\r\n        year first_year,\r\n        quantity,\r\n        price\r\nFROM\r\n    RESULT\r\nWHERE\r\n    Rank = 1\r\n\r\n```
['MS SQL Server']