首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >sqlzoo练习1

sqlzoo练习1

作者头像
皮大大
发布于 2021-03-02 16:31:59
发布于 2021-03-02 16:31:59
7820
举报

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

表结构

练习题

主要是练习where语句的使用

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

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

代码语言:javascript
复制
select name, population / area
from world
where name in ('China', 'Nigeria', 'France', 'Australia')
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-1-13,如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • 表结构
  • 练习题
  • quiz
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档