[ACCEPTED]-Select average from MySQL table with LIMIT-average
Accepted answer
I think this is what you're after:
SELECT AVG(items.price)
FROM (SELECT t.price
FROM TABLE t
WHERE t.price > '0'
AND t.item_id = '$id'
ORDER BY t.price
LIMIT 5) items
It will 2 return the average of the 5 lowest prices 1 - a single answer.
Simple solution below.
Query:
SELECT AVG(Column_name)
FROM (SELECT Column_name
FROM Table
WHERE ColumnID < number[Limit you want] )
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.