3
I cannot mount a query, the logic is:
Select produtos
with categorias
different products, being the products with more points, so I will have a product of more points of the category X, another of the category Y.
I tried to use DISTINCT
, something like:
SELECT DISTINCT categoria FROM produtos ORDER BY pontos DESC
The problem is that, in that comes the columns I need to read (only comes to categoria
..).
What do I do to solve this case?
What other columns do you need to read? If it’s columns with different values,
DISTINCT
won’t work– Maicon Carraro
columns as name, price.. the idea is to list the products by ordering them by the largest number of points, differing from the categories(want 1 product of each category, being this product of higher like). I wonder if I should wear something like Subqueries?
– Ale
Do you agree that a category may have several products at different prices? In this case you want to display which price and which product?
– Maicon Carraro
I agree, I want to select products with different categories, being the products with more points, so I will have a product of more points of the category X, another of the category Y.. That’s the idea, you understand? I’m sorry if I didn’t understand you or misinterpret you!
– Ale
Which DBMS is using?
– Maicon Carraro
I am using Mysql @Maiconcarraro
– Ale