-------子查询------------
select bumen,COUNT(*)as 人数 from haha group by bumen having COUNT(*)>=5
select MAX(nianling) from haha where bumen='销售部'
select *from haha where bumen='销售部'and nianling=56
--汇总
select *from haha where nianling = (
select MAX(nianling) from haha where bumen in(
select bumen from haha group by bumen having COUNT(*)>=5
)
)
and bumen =(select bumen from haha group by bumen having COUNT(*)>=5)
--查找男同志里面年龄最大的全部信息--
select MAX(xingming) from haha where xingbie ='男'
select *from haha where xingming =(select MAX(xingming) from haha where xingbie ='男')
---分页代码---,
select top 5*from haha
select top 5*from haha where code not in(select top 5 code from haha)
--分页代码,前面top代表一页有多少条数据,后面代码是过滤当前页的前面页面的数据
--查看一个表最多能分成多少页
select ceiling(COUNT(*)/5.0)from haha
设置主键语句
关系-添加-表和列规范后面的省略号
点击确认后完成。