SQL Exercises: Display the name of each company along with the ID and price for their most expensive product
SQL JOINS: Exercise-25 with Solution
Write a SQL query to display the name of each company along with the ID and price for their most expensive product.
Sample table: company_mast
Sample table: item_mast
SELECT A.pro_name, A.pro_price, F.com_name FROM item_mast A INNER JOIN company_mast F ON A.pro_com = F.com_id AND A.pro_price = ( SELECT MAX(A.pro_price) FROM item_mast A WHERE A.pro_com = F.com_id );
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a SQL query to display the names of the company whose products have an average price larger than or equal to Rs.350.
Next: Write a query in SQL to display all the data of employees including their department.
What is the difficulty level of this exercise?