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 |

相关推荐
一 乐3 分钟前
二手车销售|汽车销售|基于SprinBoot+vue的二手车交易系统(源码+数据库+文档)
java·前端·数据库·vue.js·后端·汽车
Databend7 分钟前
BendSQL v0.30.3 Web UI 功能介绍
数据库
gAlAxy...25 分钟前
Spring 从 0 → 1 保姆级笔记:IOC、DI、多配置、Bean 生命周期一次讲透
数据库·sqlserver
赋能大师兄32 分钟前
MyBatis缓存机制
mybatis·二级缓存·一级缓存
苦学编程的谢37 分钟前
Redis_5_单线程模型
数据库·redis·缓存
xuejianxinokok1 小时前
可能被忽略的 pgvector 各种坑
数据库·后端
拾忆,想起1 小时前
TCP粘包拆包全解析:数据流中的“藕断丝连”与“一刀两断”
java·网络·数据库·网络协议·tcp/ip·哈希算法
serve the people1 小时前
Formatting Outputs for ChatPrompt Templates(two)
前端·数据库
岁岁岁平安2 小时前
python MongoDB 基础
数据库·python·mongodb
NO.10242 小时前
11.4八股
java·linux·数据库