I have the following select in mysql:
SELECT DISTINCT
a.id,
a.unidade,
a.posicao,
a.nome,
a.peso
FROM
produtos a,
produtos_pedidos b
WHERE
a.id = b.id_produto
and b.id_pedido IN (13,12,11)
ORDER BY a.nome
Good with it I have the products of the orders 13,12,11 without repeating in alphabetical order. Well the problem and I wanted to put it in order of quantity, I tried to do the following select:
SELECT DISTINCT
a.id,
a.unidade,
a.posicao,
a.nome,
a.peso
FROM
produtos a,
produtos_pedidos b
WHERE
a.id = b.id_produto
and b.id_pedido IN (13,12,11)
ORDER BY SUM(b.qtd)
But it returns only 1 result. Does anyone know what I might be doing wrong.