I've been bugging this for the past hour..
I want to get the TOP 5 from latest data from my table clickednumbers
clickednumbers has only to columns numbers as INT & numberTime as timestamp
My query
SELECT AVG( SELECT *
FROM clickednumbers
ORDER BY numberTime DESC
LIMIT 5)
FROM clickednumbers
and im always getting the error
#1064 - You have an error in your SQL syntax;check the manual that corresponds to your MariaDB server version for the right syntanx to use near
'SELECT *
FROM clicked numbers
ORDER BY numberTime DESC '
at line 1
MariaDB Version:Server type: MariaDB
Server version: 10.1.9-MariaDB - mariadb.org binary distribution
Protocol version: 10
Sorry for bothering :(
Goal : To get the average of top 5 from latest numbers based on the numbersTime
To get the average of the top 5, use a subquery in the FROM clause:
SELECT AVG(numbers)
FROM (SELECT *
FROM clickednumbers
ORDER BY numberTime DESC
LIMIT 5
) cn;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With