数据/数据库人工智能/模式识别/机器学习精华专题

sqlzoo练习1

2020-01-13  本文已影响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')
上一篇 下一篇

猜你喜欢

热点阅读