0
Good evening, I’m using the following command:
select
cliente_id,
desconto,
pedidos_detalhes.pedido_id,
cliente_tipo
from
pedidos_detalhes
inner join
pedidos on pedidos_detalhes.pedido_id = pedidos.pedido_id;
The result is this:
How do I bring the 10 customers who got the biggest discounts per order without the same discount amount being repeated.
thank you in advance...
So I tried with this command and the result was all discounts with values 0 (Zero).
– Carlos Leandro Ferreira de Alm
I tried too... select cliente_id, discount, pedidos_details.pedido_id, cliente_type from pedidos_details Inner Join requests on request_details.pedido_id = orders.pedido_id ORDER BY discount desc LIMIT 10;
– Carlos Leandro Ferreira de Alm
I forgot to put DESC, which brings the data from the largest to the smallest. Also has the ASC option that brings the data from the smallest to the largest.
– Duque
and the result brought 0.10 discounts on all discounts, increased the LIMIT to 100 and all discounts are 0.10
– Carlos Leandro Ferreira de Alm
So with DESC brings all discounts equal to 0.10
– Carlos Leandro Ferreira de Alm
So, but in this case it is ordering the results from the highest to the lowest, if you remove the LIMIT clause 100, it will bring all the results ordered by the discount, right ?
– Duque
No, if I take the LIMIT and leave only the DESC, all the discount fields comes with value 0.10
– Carlos Leandro Ferreira de Alm
But you have all these discounts with 0.10 ?
– Duque
Let’s go continue this discussion in chat.
– Duque
So... rsrsrrss. no... if I put the group by discount it brings the discounts in descending order from 0.10 to 0.00
– Carlos Leandro Ferreira de Alm