Tuesday, 10 September 2013

Left join result sets of two unions ORACLE SQL

Left join result sets of two unions ORACLE SQL

I'm trying to pull off a rather large result set in a single block of SQL
to use as a back-end for a BI tool. Basically I want to do two union
statements that give me all data BEGINNING a month and all data ENDING a
month over the course of a year. The final result can't be one long set of
unions as I want BEGINNING and ENDING data as separate columns. What I'd
like to do is left outer join the two result sets and only get the unique
rows for Beginning and Ending along with all the common data between the
two sets. I am not entirely certain on my syntax here though.
right now I have
select yada, yada, yada, where, yada UNION select yada, yada, yada, where,
yada
How do I then say left join to another unionized set? There are about 20
cols in common and 4 outliers.

No comments:

Post a Comment