使用TOP查询
来源:互联网 发布:淘宝上传宝贝失败 编辑:程序博客网 时间:2024/05/28 20:19
使用TOP查询
查询表列前3列数据
select top 3 *from student
对学生按年龄排序返回前三列数据
select top 3 *from student order by age
返回结果集的前N条记录,以及排序字段值与第N条记录相等的记录, top n with ties 必须与order by一同使用
select top 3 with ties *from student order by age
删除年龄小于20的任意一位学生的信息
delete top(1) from studentwhere age<20
删除年龄小于21且年龄最小的以为学生
delete from studentwhere age in(select top 1 agefrom student where age <21order by age asc)
更新年龄小于22岁的任意一位学生的信息
update top(1) studentset age = age+10where age<22
更新年龄小于22岁年龄最小的一位学生的信息
update studentset age = age+10from(select top 1 id from student where age <22 order by age asc)TB_TOPwhere TB_TOP.ID = student.ID
向新创建的表中任意插入两条数据
select * into student02 from student where 1=2insert top(2) into student02output inserted.name,inserted.age,inserted.sex,inserted.addressselect name,age,sex,address from student
向新创建的新表中插入年龄最小的两条数据
select * into student03 from student where 1=2insert into student03output inserted.name,inserted.age,inserted.sex,inserted.addressselect top(2) name,age,sex,address from student order by age asc
0 0
- 使用TOP查询
- 关联查询中使用TOP引起的性能问题分析
- top使用
- 数据查询(top)
- TOP-N类查询
- 查询分页-----强势top
- TOP的sql查询
- 查询TOP-N
- mysql 实现top查询
- oracle TOP n 查询
- top查询机器情况
- MySQL查询TOP(n)
- Mysql 如何实现Top 查询
- SQL top 变量查询数据
- ORACLE 实时TOP SESSION查询
- mysql的top n查询
- MySQL的Top n 查询
- mysql实现top n查询
- 基础查询
- 杭电OJ 2009.求数列的和
- 74. Search a 2D Matrix
- poj Wireless Network(基础并查集)
- 使用JDK开发WebService-客户端建立
- 使用TOP查询
- uva 10334Ray Through Glasses
- RTMP学习(八)rtmpdump源码阅读(3)初始化与URL解析
- leecode 解题总结:324. Wiggle Sort II
- (1)第一次产品面试的感受
- Android面试题集
- 蓝桥杯2012年试题微生物增值
- redis源码分析
- PAT算法笔记(一)————A+B和C