1

this code worked fine in the Oracle live sql but when i put it on the server im getting a SQL command not properly ended was wondering if its because its different oracle versions, the server is in oracle11g

SELECT g.GID, g.Name, COUNT(*) as cnt
FROM VisitN v JOIN
     GuestN g
     ON v.GID = g.GID
GROUP BY g.GID, g.Name
ORDER BY cnt DESC
FETCH FIRST 1 ROWS ONLY;

thank you

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
Wietlol
  • 69
  • 1
  • 10

1 Answers1

4

You can use ROWNUM. For example:

select *
from (
  SELECT g.GID, g.Name, COUNT(*) as cnt
  FROM VisitN v JOIN
     GuestN g
     ON v.GID = g.GID
  GROUP BY g.GID, g.Name
  order by cnt desc
) x
where rownum = 1

See running example at db<>fiddle.

The Impaler
  • 45,731
  • 9
  • 39
  • 76