sql小习题
来源:互联网 发布:yy踢人软件 编辑:程序博客网 时间:2024/06/04 23:24
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
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
0 0
- sql小习题
- sql 习题
- 小汇编习题"HELLO?"
- 异常的小习题
- 最大堆小习题
- sql习题一
- sql习题二
- sl/sql习题总结
- SQL习题1
- SQL习题2
- SQL习题3
- Oracle 的sql习题
- SQL 课后习题数据
- 转SQL习题
- SQL习题笔记
- SQL习题笔记
- sql整理之习题..
- SQL 习题进阶 一
- spring aop 拦截器 MethodInterceptor 配置
- Perl学习(十一)——大总结基本内容
- 用UGUI做一个鼠标悬停事件
- Java程序员的日常
- 学习笔记之JavaSE(16)--面向对象编程7
- sql小习题
- 记录每一天的成长
- vue.js的ajax和jsonp请求
- vue.js进阶之组件
- mysql的一些内置函数
- java.util.concurrent翻译----Executor框架--抽象类AbstractExecutorService
- 权重--样式的优先级顺序
- 封装一个实用的日期时间选择器,时钟组件
- PHP新特性记录