D
D
danforth2017-01-06 00:02:58
MySQL
danforth, 2017-01-06 00:02:58

How to make a selection rounded up to 50?

Hello everyone, you need to calculate the number of orders placed and the amount of orders rounded up to 50.
That is, for example

заказы | сумма
34 | 50
89 | 100
185 | 150
345 | 200
164 | 250
120 | 300

The current request looks like this:
SELECT COUNT( * ) AS orders, ROUND( total, -1 ) AS total
FROM shop_order
WHERE state_id =  'completed'
GROUP BY total

But his problem is that he counts in increments of 10, i.e. orders for amounts of 10, 20, 30, 40, 50... and I'm not sure that he generally counts correctly, because the numbers come out strange, for example, there are several totals with a step of 30, 30, 30, and many are duplicated. Replaced with
GROUP BY ROUND(total, -1)
and seems to have solved the problem, but did not solve the problem of rounding up to 50.
Help me figure out how to calculate this whole thing?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question