A
A
Anton2016-10-21 14:21:38
MySQL
Anton, 2016-10-21 14:21:38

Sort by average?

Hello. How to sort records by arithmetic mean?
I have a table
id|price1|price2|price3
How to get the average of all prices and sort by it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-10-21
Reytarovsky @Antonchik

SELECT id,  ((price1 + price2 + price3)/3) as avgprice FROM table ORDER BY avgprice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question