Answer the question
In order to leave comments, you need to log in
How to make SQL selection of average values of the last 5 (by date) rows?
You need something like:
SELECT id, vendor_id, AVG(items_count) as average_items
FROM `af_vendor_stock_files`
GROUP BY vendor_id
...but you need to take the last 5 (ORDER BY created_at DESC) for each vendor_id.
How?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question