query for each row from another arbitrary query, and union results
How about:

with cte as (%(query))
select unique table.* from table join cte using (num,sub)
    where %(query_time_part);


I'm assuming here that "%(query_time_part)" is written such that it applies to the literal "table", while "%(query)" already contains the analogous code which applies to the "table" underlying "cte".

The rows that make up the cte should automatically meet the join condition to self-join, so should not need any special steps, like a UNION, for them to be emitted in their own right.  That is, the version of them that get emitted is the version that comes from "table", not from "cte", but since they are identical it doesn't matter.