首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Postgres多选

Postgres多选
EN

Stack Overflow用户
提问于 2017-05-14 12:16:29
回答 1查看 102关注 0票数 1

我有一个名为v_xml_cdr的表,它包含以下列:uuidstart_epochend_epoch。我希望能够查询表中uuidstart_epoch,然后获取该uuid,并再次查询表中start_epoch小于或等于先前找到的start_epoch的所有调用,以及end_epoch大于或等于先前找到的相同start_epoch的所有调用。这是我到目前为止所拥有的,但它返回一个空的结果集。它应该返回5行。

代码语言:javascript
复制
select count(uuid)
from v_xml_cdr
where start_epoch
      <= (select start_epoch as reject_start
          from v_xml_cdr
          where uuid = '5c076428-3790-11e7-868a-xxxxx'
         )
  and end_epoch
      >= (select start_epoch as reject_start
          from v_xml_cdr
          where uuid = '5c076428-3790-11e7-868a-xxxxx'
         );
EN

回答 1

Stack Overflow用户

发布于 2017-05-14 12:43:09

我想你想要的是:

代码语言:javascript
复制
select count(uuid)
from v_xml_cdr xc join
     (select min(start_epoch) as minse
      from v_xml_cdr xc1
      where uuid = '5c076428-3790-11e7-868a-xxxxx'
     ) xc1
     on xc.start_epoch <= xc1.minse and
        xc.end_epoch >= xc1.minse;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43960319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档