I have a table called v_xml_cdr and have a the following columns: uuid, start_epoch and end_epoch. I want to be able to query the table for the start_epoch of of a uuid and then take that uuid and query the table again for all calls that have a start_epoch of less than or equal to the start_epoch from the previously found uuid and an end_epoch of greater than or equal to that same previously found start_epoch. Here is what I have so far, but it returns an empty result set. It should return 5 rows.
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'
);
WHERE (SELECT ...) BETWEEN start_epoch AND end_epoch). Can you provide sample data to prove that the query does not do what you want? Can you verify that the subselect returns a single row and not NULL?