Reputation: 41
I am trying to execute this query:
DELETE from TABLE1A
WHERE X IN
(SELECT A.X FROM
(SELECT X, r1.Y, r2.Y, DENSE_RANK() OVER (PARTITION by r1.Y, r2.Y ORDER by X) as RANK
FROM TABLE1B r0
INNER JOIN TABLE1A r1 on r0.X = r1.X
INNER JOIN TABLE1A r2 on r0.X = r2.X
WHERE r1.Y = foo and r2.Y = bar
) AS A WHERE A.RANK > 1
);
After executing it, am getting the error: SQL Error [268] [HY000]: SAP DBTech JDBC: [268] (at 63): column ambiguously defined: X
What could possibly go wrong in that query?
Upvotes: 0
Views: 611
Reputation: 10388
Tables R1 and R2 both seem to have columns named X
, but in the ORDER BY
part on the window function you don’t specify which of these columns should be used; thus the error message.
Upvotes: 1