繁体   English   中英

Postgresql 查询以检查字符串中断

[英]Postgresql query to check string break

我在 postgresql 中执行数字序列中断搜索时遇到问题,例如,如果我的 seq 列乱序,我将收到 email 的通知,例如我的序列is: 340,341,342如果is: 340 342,343这与一个序列失败

您可以使用下一个查询来查找异常:

select count(*) from (
  select id - (lag(id) over (order by id)) diff from tbl
) t where diff is not null and diff <> 1;

当查询结果不是 0 时发现异常

SQL 在线编辑器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM