sql 取两值之间的数据方法(例:100-200之间的数据)
时间:2024-01-24 03:55:20
题:取表table中100条-200条之间数据
方法1:临时表
select top 200 * into #aa from table order by time-- 将top m笔插入 临时表
set rowcount 100
select * from #aa order by time desc
--drop table #aa --删除临时表
方法2:
select top 100 * from
(select top 200 * from table order by time asc) a
order by time desc
方法3:not in
select top 100 * from v_company where (
id not in
(select top 100 id from v_company order by id asc)
) order by id asc
这里只列举3种我测试的方法,还有别的方案就由高手补上了,3种方案的效率也不竞相同,我一直认为not in效率不好,但在这里使用not in速度最快,请高手补充说明,谢谢
标签:sql,两值之间
0
投稿
猜你喜欢
Hugo 游乐场内容初始化示例详解
2024-05-10 13:58:13
浅谈python 四种数值类型(int,long,float,complex)
2023-12-17 05:26:48
浅谈Mybatis+mysql 存储Date类型的坑
2024-01-17 19:13:14
ASP实现GB2312转UTF-8函数
2009-02-26 13:08:00
原创一个AJAX类
2008-07-24 13:29:00
fso对象CreateTextFile方法调用时“无效的过程调用或参数”错误
2009-05-26 15:39:00
Gradio机器学习模型快速部署工具quickstart前篇
2023-07-01 15:07:51
Python pickle模块实现对象序列化
2022-03-04 03:51:22
教你使用pyinstaller打包Python教程
2021-01-20 01:07:28
python3中set(集合)的语法总结分享
2022-06-06 21:44:56
SQL窗口函数之聚合窗口函数的使用(count,max,min,sum)
2024-01-21 00:56:09
零基础写python爬虫之urllib2中的两个重要概念:Openers和Handlers
2023-06-19 20:06:16
用ASP实现分级权限控制
2008-10-09 13:02:00
centos7中如何利用crontab进行mysql定时备份
2024-01-28 00:50:34
在pandas中一次性删除dataframe的多个列方法
2022-08-16 02:50:02
Centos8(最小化安装)全新安装Python3.8+pip的方法教程
2022-11-09 06:00:27
python3下pygame如何实现显示中文
2021-01-15 00:57:04
xmlHttp msxml3.dll 错误 '800c0008' 解决办法
2008-08-31 20:44:00
新年伊始,看各大网站新春LOGO
2009-01-01 19:35:00
如何利用Python批量处理行、列和单元格详解
2023-02-05 05:07:35