I am trying to get the average of the lowest 5 priced items, grouped by the username attached to them. However, the below query gives the average price for each user (which
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 return the average of the 5 lowest prices - a single answer.
Simple solution below.
Query:
SELECT AVG(Column_name)
FROM (SELECT Column_name
FROM Table
WHERE ColumnID < number[Limit you want] )