Answer the question
In order to leave comments, you need to log in
How to make a query with sorting in MySQL?
there is a mysql table
contains fields rate and amount
it contains many values rate = 0.01 and different amounts
also contains many different values rate and different amounts
I want to get all amounts for the first 15 values rate = 0.01, 0.03, 0.04 ... 0.16
This command returns 15 amount values for one rate:
"SELECT * FROM `cell` WHERE `buy_cell` = 0 ORDER BY `rate` DESC LIMIT 15"
Answer the question
In order to leave comments, you need to log in
Depending on how the result is expected
SELECT * FROM `cell` WHERE `buy_cell` = 0 AND rate BETWEEN 0.01 AND 0.16 ORDER BY `rate` DESC
or
SELECT *, GROUP_CONCAT(amount) FROM `cell`
WHERE `buy_cell` = 0 AND rate BETWEEN 0.01 AND 0.16
GROUP BY rate
ORDER BY `rate` DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question