Skip to content
Advertisement

Compare dates from two queries PL/SQL

I have two queries , the first gets some data back from my table, the second query displays all half hour times between two specified dates. Is there a way of comparing the date results from query 1 from query 2 and merge the two results together when the date from query 2 doesn’t exist in query 1 result.

I’ll attach a little diagram to show what I mean. enter image description here

Query 1:

Query 2:

Advertisement

Answer

You can enumerate the timestamps you want in a CTE, then bring the table with a left join:

I like to use recursive queries rather than Oracle specific connect by syntax, because they are standard SQL – but that’s mostly a matter of taste, the logic remains the same.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement