2019-03-14
阅读量:
813
联合查询2
类型转换88->88.00
select cast(88 as decimal(4,2))
输出字符串 '11'
select cast(1 as char(1))+'1'
创建视图,视图中存储的是select语句,而不是结果集数据,常用的复杂语句存到一个视图里
create view ab
as
select * from student --视图的内容是一个select语句
select * from ab
删除视图
drop view ab
子查询,在班级表里的各个班级的学生信息
select * from student
where cid in (select distinct cid from class)
exists关键字,大数据效率更高些
select * from student
where exists
(select * from class where student.cid=class.cid)
将性别作两列,分别显示年龄
select name 姓名,
max(case when gender='1' then age else 0 end) 男,
avg(case when gender='0' then age else 0 end) 女
from student
group by name
0.9178
1
2
关注作者
收藏
评论(0)
发表评论
暂无数据

