2

I just want to get the first result of this query but whenever I write down LIMIT. Oracle SQL Developer throws me this error

*ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause:
Action: Error at Line: 6 Column: 7

Here is the Code:

SELECT IDBAR FROM ( SELECT PARRANDEROS.FRECUENTAN.ID_BAR as IDBAR,

COUNT(PARRANDEROS.FRECUENTAN.ID_BAR) c 
FROM PARRANDEROS.FRECUENTAN
GROUP BY PARRANDEROS.FRECUENTAN.ID_BAR
ORDER BY c DESC
) 

LIMIT 1;

I've tried this method too:

SELECT IDBAR FROM ( SELECT PARRANDEROS.FRECUENTAN.ID_BAR as IDBAR,

COUNT(PARRANDEROS.FRECUENTAN.ID_BAR) c 
FROM PARRANDEROS.FRECUENTAN
GROUP BY PARRANDEROS.FRECUENTAN.ID_BAR
ORDER BY c DESC
LIMIT 1

);

Thanks a Lot.

David Cruz
  • 2,967
  • 2
  • 26
  • 40
  • The error message implies that you are using an Oracle database. The use of `LIMIT` implies that you are thinking MySQL. (Never mind that MySQL is owned by Oracle.) – Rick James Mar 01 '15 at 23:31

1 Answers1

1

Thanks to @Jim Garrison. The solution was to use the ROWNUM attribute:

SELECT IDBAR FROM ( SELECT PARRANDEROS.FRECUENTAN.ID_BAR as IDBAR, 
COUNT(PARRANDEROS.FRECUENTAN.ID_BAR) c 
FROM PARRANDEROS.FRECUENTAN
GROUP BY PARRANDEROS.FRECUENTAN.ID_BAR
ORDER BY c DESC
) 

WHERE ROWNUM <= 1;
David Cruz
  • 2,967
  • 2
  • 26
  • 40