sql小习题

1.创建一张学生表,包含学号,姓名,性别,家庭住址,联系电话信息
create table students
(id int primary key AUTO_INCREMENT,
n_um int,
age char,
sex char,
address char,
telphone CHAR
)
2.修改学生表结构,增加学历字段
alter table students add education char(25)
3.随机插入3条学生信息
Insert into students values('','4120','21','男','地址','13131313')
Insert into students values('','4120','21','男','地址','13131313')
Insert into students values('','4120','21','男','地址','13131313')

4.查询出年龄小于20岁,学历为本科的所有学员信息
select *from students where age < '20' and education = '本科'
5.统计所有学生的男女人数
select sex,count(sex) from students GROUP BY sex
6.统计学生年龄在15-20,20-25,25-30三个区间的人数分别为多少
select case when (age >=15 and age <=20) then '15-20' when (age >=20 and age <=25) then '20-25' when (age >=25 and age <=30) then '25-30' else '30-' end 'eag_layer', count(*) emps from students group by case when (age >=15 and age <=20) then '15-20' when (age >=20 and age <=25) then '20-25'  when (age >=25 and age <=30) then '25-30' else '30-' end order by 1
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luyaran

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值