Weather Observation Station 5

  • + 1 comment

    Yes, you can do it in one statement:

    SeLeCt t3.CITY,t3.l from ( SELECT min(t.l) as 'min', max(t.l) as 'max' from (select CITY, CHAR_LENGTH(CITY) as 'l' from STATION ORDER BY CHAR_LENGTH(CITY) ) t ) t2, (select CITY, CHAR_LENGTH(CITY) as 'l' from STATION ORDER BY CHAR_LENGTH(CITY) ) t3 WhErE t2.min = t3.l limit 1 union all SeLeCt t3.CITY,t3.l from ( SELECT min(t.l) as 'min', max(t.l) as 'max' from (select CITY, CHAR_LENGTH(CITY) as 'l' from STATION ORDER BY CHAR_LENGTH(CITY) ) t ) t2, (select CITY, CHAR_LENGTH(CITY) as 'l' from STATION ORDER BY CHAR_LENGTH(CITY) ) t3 WhErE t2.max =t3.l