100 % || INTUITIVE && WELL - EXPLAINED || EASY SQL QUERY || Using USING( ) || Beats 97.11 %.. || Ex.
Intuition\n Describe your first thoughts on how to solve this problem. \nSELECT product_name, SUM(unit) AS unit --> show product_name as well as sum of unit col
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSELECT product_name, SUM(unit) AS unit --> **show** product_name as well as **sum** of unit column **alias** as unit...\nFROM Products INNER JOIN Orders --> we have to **join** both tables using **INNER** JOIN...\nUSING(product_id) --> **joining** w.r.t. **product_id**...\nWHERE MONTH(order_date) = 2 AND YEAR(order_date) = 2020 --> **Month** should be **Feb** & **year** should be **2020**...\nGROUP BY product_id --> **Grouping** w.r.t. **product_id**...\nHAVING unit >= 100; --> unit should be >= 100(Conditions given in the problem)...\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsing Fundamentals of **SQL**...\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nSELECT product_name, SUM(unit) AS unit \nFROM Products \nINNER JOIN Orders \nUSING(product_id) \nWHERE MONTH(order_date) = 2 AND YEAR(order_date) = 2020 \nGROUP BY product_id \nHAVING unit >= 100;\n```
['Database', 'MySQL']