sql 查询

连续区域取数

select sid,min(b.eid) as eid from

(select id+2 as sid from txtTempTable where tc1 like 'Name*') as a,

(select id as eid from txtTempTable where tc1='Page') as b

where sid<b.eid

group by sid

16,18, 22,23

|----|-----|-----|
| id | tc1 | tc2 |
| 16 | | |
| 17 | | |
| 18 | | |
| 22 | | |
| 23 | | |

两表对应关联

select aa.sid,aa.eid,

(select top 1 tc2 from txtTempTable where tc1 like "Analyte*" and id>aa.sid-14 and id<aa.eid)

as xmmc from

(

select sid,min(b.eid) as eid from

(select id+2 as sid from txtTempTable where tc1 like 'Name*') as a,

(select id as eid from txtTempTable where tc1='Page') as b

where sid<b.eid

group by sid

) as aa

|-----|-----|-----|
| sid | eid | mc |
| 16 | 18 | f01 |
| 22 | 23 | f02 |

相关推荐
Full Stack Developme7 小时前
数据库索引的原理及类型和应用场景
数据库
IDC02_FEIYA9 小时前
SQL Server 2025数据库安装图文教程(附SQL Server2025数据库下载安装包)
数据库·windows
辞砚技术录9 小时前
MySQL面试题——联合索引
数据库·面试
萧曵 丶10 小时前
MySQL 主键不推荐使用 UUID 的深层原因
数据库·mysql·索引
小北方城市网10 小时前
分布式锁实战指南:从选型到落地,避开 90% 的坑
java·数据库·redis·分布式·python·缓存
毕设十刻10 小时前
基于Vue的人事管理系统67zzz(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js
张较瘦_10 小时前
SpringBoot3 | MyBatis-Plus 搞定宠物管理:从0到1实现增删改查
mybatis·宠物
TDengine (老段)12 小时前
TDengine Python 连接器入门指南
大数据·数据库·python·物联网·时序数据库·tdengine·涛思数据
萧曵 丶12 小时前
事务ACID特性详解
数据库·事务·acid
kejiayuan13 小时前
CTE更易懂的SQL风格
数据库·sql