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 |

相关推荐
岳麓丹枫00140 分钟前
PostgreSQL 中 pg_wal 目录里的 .ready .done .history 文件的生命周期
数据库·postgresql
陌上丨7 小时前
Redis的Key和Value的设计原则有哪些?
数据库·redis·缓存
AI_56787 小时前
AWS EC2新手入门:6步带你从零启动实例
大数据·数据库·人工智能·机器学习·aws
ccecw7 小时前
Mysql ONLY_FULL_GROUP_BY模式详解、group by非查询字段报错
数据库·mysql
JH30737 小时前
达梦数据库与MySQL的核心差异解析:从特性到实践
数据库·mysql
数据知道8 小时前
PostgreSQL 核心原理:如何利用多核 CPU 加速大数据量扫描(并行查询)
数据库·postgresql
麦聪聊数据9 小时前
Web 原生架构如何重塑企业级数据库协作流?
数据库·sql·低代码·架构
未来之窗软件服务9 小时前
数据库优化提速(四)新加坡房产系统开发数据库表结构—仙盟创梦IDE
数据库·数据库优化·计算机软考
程序员侠客行10 小时前
Mybatis连接池实现及池化模式
java·后端·架构·mybatis
Goat恶霸詹姆斯10 小时前
mysql常用语句
数据库·mysql·oracle