Can any one explain me how the following query works?The following query is wokring fine in production but it failed in test after recent upgrade of teradata:
INSERT INTO DATABSE.SCGR01TABLE
ROW_NUMBER() OVER (ORDER BY ABD.account) AS ROW_NUM
,'Z' AS country
,10 AS code
FROM database.sometable ABD
WHERE NOT EXISTS
FROM masterdb.mastertable zzz
WHERE abd.account = zzz.account
AND zzz.code = 'z'
AND zzz.code = 10
GROUP BY abd.number) /*when you execute this query alone, it fails in prodn. but as a whole its works fine*/
GROUP BY abd.nu,ber,abd.account ;
Is it because the GROUP BY clause refers to the column of table which is not a part of the inner query? Not sure.