Skip to content
Advertisement

MySQL Query selection

I have a big database table called pricing. The fields are following:

id code description rrp buy stock date distributor vendor version

User select the vendor field only. version field can be vary for each distributor. I need to display all the details from pricing table but only the recent version of each distributor. For that I am trying to get all distributors and it’s recent version. I have coded as below:

But the output shows all versions of distributors, like below:

How can I display only the latest version of each distributor?

So the output should be:

Advertisement

Answer

Your grouping by distributor, version makes it so that any unique combo of distributor and version is a separate group. This is what is being displayed in your output. I think you only want to group by distributor if I’m reading the question right.

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