Answer: Using JOIN and Aggregate Window Function
Find a detailed explanation of using JOIN and the aggregate window function.
We'll cover the following...
We'll cover the following...
Solution
The solution is given below:
Code explanation
The explanation of the solution code is given below:
Lines 2–5: The
SELECTstatement selects the columnsPName,Category, and the maximum price of the product in each category using the aggregate window function. We useASto set an alias for the columns and tables.Line 6: The data is retrieved from the
Productstable.Line 7: The
JOINis performed betweenProductsandProductCategoriestables on theCategoryIDcolumns in both tables.
Recalling relevant concepts
We have covered the following concepts in this question:
Selective columns
Aliases
About joins
Aggregate functions
Window functions
Let’s discuss ...