Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
657 views

I'm attempting to figure out what's going on with an existing query that has numerous "set" operators. Various web searches and a cursory reading of the Teradata documentation have yielded no results.

Here's a pseudo-code version of the query I'm interested in:

SELECT column from table1
UNION
SELECT column from table2
UNION
SELECT column from table3
MINUS 
   (select column from table 4)
UNION
SELECT column from table4

I'm primarily curious about how the MINUS is handled; does it eliminate rows only from the immediately previous SELECT from table3 or from the entire result set? Also, the parentheses in the MINUS statement are there in the code I'm inspecting.

Furthermore, I'm presuming that the final UNION is not in any way affected by the MINUS procedure.

I'm sure I could figure this out myself by creating some sample tables, but I don't have access to the database right now I've checked in PostgreSQL docs and read blogs. (trying to get some work done from home today).

in Competitive-Programming by Expert (650 points) | 657 views

Please log in or register to answer this question.