数据分析4"/>
数据分析4
一:基础语句
1.1 select
select from
从表中返回指定的字段,一行代码不用分号
selec * from
返回表全部内容
selec A as B from
把A的列名改成B,然后返回
select distinct A from
只返回A列不一样的数据
select A/B C from
将a除以b的值命名为c返回
1.2 where(加在from后面)
例子1:人口大于两个亿国家的人均gdp
select gdp/population 人均gdp from world where population>=2000000000
例子2:中国的人口
select population from world
where name='CHina'
注意:等于字符串数据需要加单引号,不能是双引号,另外,字符串并不区分大小写。
例子3:中国和美国的人口
select population from world
where name in ('china','america')
select population from world
where name=’china‘ or name='america'
括号中数据表示一个列表
例子4:面积在250000和300000之间的国家名称和面积
select area, name from world
where area between 25000 and 300000
例子5:查询以c开头ia结尾的国家的名称(模糊查询 like )
select area, name from world
where name like 'c%ia'
例子6:查询第二位是t的国家的名称
select area, name from world
where name like '_t%'
例子6:查询名称中有两个o,被两个字符隔开
更多推荐
数据分析4
发布评论