I try to JOIN table with the result return from UNION sub query. But I get syntax error from the query below. Is it possible to achieve such task with Pervasive database? I am using Pervasive v8.
SELECT * FROM
Table1 INNER JOIN Table2 ON Table1.BKAR_INV_NUM = Table2.BKAR_INVL_INVNM
INNER JOIN
(
SELECT BKAR_INVL_INVNM as SO_Num, BKAR_INVL_CNTR as Line, BKAR_INVL_ASD as Due_Date FROM Table3
UNION SELECT BKAR_INVL_INVNM as SO_Num, BKAR_INVL_CNTR as Line, BKAR_INVL_ASD as Due_Date FROM Table4 WHERE BKAR_INVL_ASD IS NOT NULL
) AS SubTable
ON SubTable.SO_Num = Table1.BKAR_INV_SONUM AND SubTable.Line = Table2.BKAR_INVL_CNTR
According to my research, Pervasive v8 supports UNION, but it doesn't support sub query.