You are viewing a single comment's thread. Return to all comments →
SIR CAN YOU EXPLAIN THIS PLEASE
SET @V1 := (SELECT MIN(LENGTH(CITY)) FROM STATION);
SET @V2 := (SELECT CITY FROM STATION WHERE LENGTH(CITY) = @V1 ORDER BY CITY LIMIT 1);
SET @V3 := (SELECT MAX(LENGTH(CITY)) FROM STATION);
SET @V4 := (SELECT CITY FROM STATION WHERE LENGTH(CITY) = @V3 ORDER BY CITY LIMIT 1);
PLease explain this
Thanks dhananjay.. it worked :-)
I second it. Can you please explain this.
This query is about unifying the results of two subqueries, so we use the UNION clause.
The WHERE ROWNUM = 1 in both subqueries is there in order to do a "TOP 1". That is the way this is done in Oracle. It is not very didactic but that's how Oracle undestands it. A simple explanation for that is here: https://stackoverflow.com/questions/3451534/how-do-i-do-top-1-in-oracle
The reason of what I have put in the ORDER BY, I think it is due to the statement of the challenge, but I'd have to look into it again.
All the best!