按导演名排重列出所有电影(只显示导演),并按导演名正序排列
select distinct director from movies order by director;
列出按上映年份最新上线的4部电影
SELECT * FROM movies order by year desc limit 4;
按电影名字母序升序排列,列出前5部电影
SELECT * FROM movies order by title limit 5;
按电影名字母序升序排列,列出上一题之后的5部电影
SELECT * FROM movies order by title limit 5 offset 5;
如果按片长排列,John Lasseter导演导过片长第3长的电影是哪部,列出名字即可
SELECT title FROM movies where director ='John Lasseter' order by Length_minutes desc limit 1 offset 2;
按导演名字母升序,如果导演名相同按年份降序,取前10部电影给我
SELECT * FROM movies order by director,year desc limit 10 ;
North_american_cities
列出所有加拿大人的Canadian信息(包括所有字段)
SELECT * FROM north_american_cities where country='Canada';
列出所有美国United States的城市按纬度从北到南排序(包括所有字段)
SELECT * FROM north_american_cities where country = 'United States' order by Latitude desc ;
列出所有在Chicago西部的城市,从西到东排序(包括所有字段)
SELECT * FROM north_american_cities where Longitude <-87.629798 order by Longitude;
用人口数population排序,列出墨西哥Mexico最大的2个城市(包括所有字段)
SELECT * FROM north_american_cities where Country ='Mexico' order by Population desc limit 2;
列出美国United States人口3-4位的两个城市和他们的人口(包括所有字段)
SELECT * FROM north_american_cities where Country ='United States' order by Population desc limit 2 offset 2;
北美所有城市,请按国家名字母序从A-Z再按人口从多到少排列看下前10位的城市(包括所有字段)
SELECT * FROM north_american_cities order by Country,Population desc limit 10;
网友评论