I have two different tables with headers (shortened)
table a
supplier_id, company_name
table b
product_id, product_name, supplier_id, unit_price
I have to produce a table with only maximum unit price products of each company. The header of the resulting table is: company_name, product_name, unit_ price
.
My code is actually selecting each product.
SELECT suppliers.company_name AS company, products.product_name AS product, MAX(products.unit_price) AS price FROM suppliers
JOIN products
ON products.supplier_id = suppliers.supplier_id
GROUP BY company_name, product_name, unit_price
ORDER BY price DESC;
Company Product Max unit price
company a product x value 1
company b product y value 2