Unable to execute nested SQL queries in Spark SQL

Viewed 387
1 Answers

I'm not sure that SparkSQL supports TOP. But it is not needed. Does this work?

SELECT t.COLUMN
FROM TABLE t           
WHERE t.COLUM_1 = '9999-12-31' AND
      NOT EXISTS (SELECT 1 FROM TABLE2 ET WHERE ET.COl1 = t.COL2);

This fixes a few other syntax issues with the query (such as no alias A).

LIMIT in the subquery is also not needed. NOT EXISTS should stop at the first match.

Related