Skip to content
Advertisement

MySQL output gives values from different rows

I am working on sql and there are 4 different columns which are pname, Fname,Flastname and amount. It gives the correct outputs for pname and amount but fname and flastname are from different rows which are not related to the amount and pname. The query should output the following question: Find the names of farmers who sells most for each product in the website.

I have 2 attributes which are farmers and buys:

my sql code is below:

Advertisement

Answer

Get the max amount per product in a sub-query and join against that query

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement