SQL How to find average value of SQL statement using LIMIT?

I am currently working with a database on phpmyadmin. I am trying to find a Tool for an SQL statement that implements LIMIT code.

SQL statement -

SELECT avg (value) FROM que LIMIT 10

The problem with the code is that it does not average the first 10 numbers in the value column, but all of them. Thus, LIMIT 10 does not actually work. Is there a way to avoid this or an alternative?

+4
source share
1 answer

You need to use a subquery:

SELECT avg(value)
FROM (select value
      from que
      LIMIT 10
     ) q;

, , limit order by - " ".

+8

All Articles