sqlzoo练习1

作者: 皮皮大 | 来源:发表于2020-01-13 16:30 被阅读0次

开始进行SQL的练习,选择了sqlzoo网站

image

表结构

image

练习题

主要是练习where语句的使用

-- 1
SELECT population FROM world
WHERE name = 'Germany'
  
-- 2
SELECT name, population FROM world
WHERE name IN ('Sweden', 'Norway','Denmark');

-- 3
SELECT name, area FROM world
WHERE area BETWEEN 200000 AND 250000

quiz

  1. 产生下表的结果
image
select name, population
from world
wher populantion between 1000000 and 1250000
  1. 通配符使用
select name, population
from world 
where name like "AL%"  -- AL开头的名字
image
  1. Select the code which shows the countries that end in A or L
select name 
from world 
where name like "a%" or name like "%l"
  1. 代码运行结果
select name, length(name)
from world 
where length(name)=5 and region="Europe"
image
  1. 代码运行结果
select name, area*2
from world 
where population = 64000
image
  1. Select the code that would show the countries with an area larger than 50000 and a population smaller than 10000000
select name, area, population
from world 
where area > 50000 and population < 1000000;
  1. Select the code that shows the population density of China, Australia, Nigeria and France

笔记:题目中要求的是人口密度

select name, population / area
from world 
where name in ('China', 'Nigeria', 'France', 'Australia')

相关文章

网友评论

    本文标题:sqlzoo练习1

    本文链接:https://www.haomeiwen.com/subject/yucnactx.html