Advertisement
Infernale

The Easy City 2 [NCTU Floor 25]

Dec 24th, 2019
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.75 KB | None | 0 0
  1. #16 first 3 character of nth smallest/largest country and its cities
  2. SELECT SUBSTR(country, 1, 3), COUNT(city) Cities
  3.     FROM citytable
  4.         GROUP BY country
  5.         ORDER BY Cities ASC LIMIT 1, 1;
  6.        
  7. #17 Delete data where name of city starts or ends with specified character or lat/lon between some values
  8. DELETE FROM citytable
  9.     WHERE city RLIKE "[nugi]$" OR city RLIKE "^[^wx]" OR
  10.           lat BETWEEN 121.5 AND 125.5 AND lon BETWEEN 25.3 AND 25.5;
  11.  
  12. #18 Swap(lat, lon) if last number of ID is m
  13. UPDATE citytable
  14.     SET lat = lat + lon, lon = lat-lon, lat = lat - lon WHERE id % 10 = 4;
  15.    
  16. #19 Euclidean distance between smallest lat, lon and largest lat, lon
  17. SELECT ROUND(SQRT(POW(MAX(lat) - MIN(lat), 2) + POW(MAX(lon) - MIN(lon), 2)), 4)
  18.     FROM citytable;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement