I guess you need to alias the derived table. I don't know if this is ANSI requirement or a Teradata requirement.
sel count(*) from
(select * from p1
union
select * from p2
) a;
^^^^
*** Query completed. One row found. One column returned.
Count(*)
-----------
2
sorry about that.
-------------------------------------
DOH! I guess I need a refresher course on SET logic.
Again the MINUS will only work if you don't have any duplicate rows which are allowed in ANSI MULTISET tables.
For years Teradata Didn't support Multi-set tables because it was true to the original Codd/Date relational model and how can a set contain the same value twice. Typically leads to referential integrity problems.
Here is what I mean about the multi-set tables.
----------------------------
ins p1 (1,0);
ins p1 (2,0);
Then insert the same rows again.
ins p1 (1,0);
ins p1 (2,0);
Then only insert one set of the rows into the second table.
ins p2 (1,0);
ins p2 (2,0);
----------------------------
select count(*) from p1;
*** Query completed. One row found. One column returned.
Count(*)
-----------
4
----------------------------
select count(*) from p2;
*** Query completed. One row found. One column returned.
Count(*)
-----------
2
----------------------------
sel count(*) from
(select * from p1
union
select * from p2
) a;
*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.
Count(*)
-----------
2
----------------------------
select * from p1
minus
select * from p2;
*** Query completed. No rows found.
----------------------------
select * from p2
minus
select * from p1;
*** Query completed. No rows found.
-----------------------
But we know the tables aren't identical because one has 4 rows and one only has 2. Therefore both the Union and the Minus give you the wrong answer that the tables are identical.
-------