I have SQL query below where I am attempting to average a set of integers over the last 5 minutes. But I am getting the error that the subquery is returning more than one value, which is what I want it to do, I am just unaware of how to get the average for the top 300 values like I am wanting.
SELECT AVG(value) AS AVERAGE,
id_num
FROM table_name
AS C
WHERE C.time=(SELECT TOP 300 time FROM table_name)
GROUP BY id_num
Rather than using the = operator, use the IN operator
edit: added order by as suggested