You are viewing a single comment's thread. Return to all comments →
I get an error when trying this:
SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY), CITY FETCH FIRST 1 ROWS ONLY
ERROR at line 1:
ORA-00933: SQL command not properly ended
this is not a right query or syntex. please do read about syntex of "ORDER BY" and also on "HAVING" clause.
the syntax for ORDER BY is correct. If I run the exact same query without the FETCH clause then the query works just fine.
Going off these docs, my query with FETCH should work just fine. https://oracle-base.com/articles/12c/row-limiting-clause-for-top-n-queries-12cr1
Try this in "oracle" envoirment:
select city,length_city from (select a.*, rownum r from (select length(city) length_city,city from station order by length_city, city) a) where r in (1,(select count(*) from station))
Yes I'm using Oracle DB, as my original post stated.
Thank you for your answer, but I am wondering why Oracle's FETCH clause is not working here...
Can you explain this query?
if there are more cities with length 21 this doesnt work
Semicolon is missing