I am practicing on SQL and I am having this problem
[** From the following tables write a SQL query to find the most expensive product of each company. Return pro_name, and com_name**] [1]: https://i.stack.imgur.com/jtJ85.png
this problem can be solved using a sub query on the WHERE clause, however am trying to solve this problem using GROUP BY, is there a way?
I tried solving it using this code
*
SELECT COM_NAME,PRO_NAME, MAX(PRO_PRICE)
FROM company_mast C
JOIN item_mast I
ON C.COM_ID=I.PRO_COM
GROUP BY COM_NAME,PRO_NAME
I realized that the group by is done on the PRO_NAME not the COM_NAME which I think is because PRO_NAME has more elements then COM_NAME am I right? and is there a way to solve it using GROUP BY