Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Get the 10 biggest numbers

I'm trying to retrive the 10 biggest numbers from a table called bonus.

But I'm getting this error message:

Incorrect syntax near 'LIMIT'

My code:

SELECT cust_nr, period1_bonus FROM bonus ORDER BY period1_bonus DESC LIMIT 10
like image 338
dumbel Avatar asked Nov 29 '22 04:11

dumbel


2 Answers

Try this instead:

SELECT TOP 10 cust_nr, period1_bonus FROM bonus ORDER BY period1_bonus DESC

LIMIT <x> is a mySQL construct, not an MSSQL construct. TOP should work for you here.

like image 67
Jimmy Sawczuk Avatar answered Dec 04 '22 07:12

Jimmy Sawczuk


Try SELECT TOP

SELECT TOP 10 cust_nr, period1_bonus 
FROM bonus 
ORDER BY period1_bonus DESC
like image 26
Oleg Grishko Avatar answered Dec 04 '22 08:12

Oleg Grishko