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 |

相关推荐
kiss strong7 分钟前
redis服务器登录(内网环境,无法使用客户端)
数据库·redis·缓存
志栋智能14 分钟前
运维超自动化中的配置管理实践
运维·网络·数据库·自动化
邪修king24 分钟前
MySQL 数据库(三):表级操作实战:增删查改全实例演示 + 企业实操红线规范
android·数据库·mysql
知行产研35 分钟前
煤矿软件杀成红海,龙软科技押注的“时空智能“能接棒吗?
数据库·科技·mysql
2501_9336707938 分钟前
内部审计校招的数据化趋势:SQL、Excel、Power BI和证书选择
数据库·sql·excel
倔强的石头_1 小时前
异构数据同步最难的不是“搬过去”:我如何理解 KFS 的全周期一致性校验
数据库
anxiao_m1 小时前
工业桌面云怎么选?从算力、适配、安全多维度实测对比
数据库·云桌面·云桌面厂家
qq_349447951 小时前
搭建mysql主从数据库
数据库·mysql
白帽黑客-晨哥1 小时前
Copilot 能换成本地吗?本地化 AI 编程助手完全指南
数据库·人工智能·copilot