When using Order By it does not take the stock correctly

Viewed 23

the idea is that it takes the group by in descending order, but it doesn't do it

SELECT * FROM dev_transacciones GROUP BY id_producto order by stock ASC

1 Answers

This should do what you're looking for:

    SELECT * FROM dev_transacciones GROUP BY id_producto order by stock DESC 

ASC stands for Ascending, and DESC stands for Descending.

I recommend that you read through this site:

https://www.plus2net.com/sql_tutorial/sql_order_by.php

In order to understand more about how these orders in SQL are generated.

Related