我有一个名为v_xml_cdr的表,它包含以下列:uuid、start_epoch和end_epoch。我希望能够查询表中uuid的start_epoch,然后获取该uuid,并再次查询表中start_epoch小于或等于先前找到的start_epoch的所有调用,以及end_epoch大于或等于先前找到的相同start_epoch的所有调用。这是我到目前为止所拥有的,但它返回一个空的结果集。它应该返回5行。
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'
);发布于 2017-05-14 12:43:09
我想你想要的是:
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;https://stackoverflow.com/questions/43960319
复制相似问题