11.25 MySQL学习记录

select *
from world.country;

/*新建一列,upper将文本全部转为大写 lower全部转为小写*/
select district, upper(district) as district_upcase
from world.city
order by district;

/*求某一特定列的平均值*/
select avg(lifeexpectancy) as avg_life
from world.country
where continent = 'africa';

/*计算该行的列数*/
select count(Name) as num_name
from world.country;

/*计算总和*/
select sum(population) as sum_poplulation
from world.country
where continent = 'asia'

/*第十课 分组数据*/

/*group by子句根据continent排序并分组, 会对每一个continent而不是整个表计算total_number*/
select continent, count(*) as total_num
from world.country
group by continent;

/*having过滤分组;where过滤行。having过滤大于拥有30个国家的Continent组*/
select Continent, count(*) as num_country
from world.country
group by Continent
having count(*) >= 30;

 

转载于:https://www.cnblogs.com/vincenthe1/p/7894784.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值