删除(选择...)SAP HANA

时间:2018-05-15 16:09:50

标签: sql subquery sap delete-row hana

这可能是SAP HANA特有的,但是为什么这不起作用,是否有推荐的解决方法:

DELETE FROM
(SELECT
 PKID
, a
, b)
Where a > 1 

"("

有一个语法错误

实际上,DELETE FROM (TABLE) where a > 1也不起作用,并提供相同的语法错误。

问题是我需要删除标记的特定行,在我的select语句中使用了Rank函数。

谢谢(第一篇文章,潜伏着并永远搜索)。

-CW

1 个答案:

答案 0 :(得分:0)

感谢您的回复。我现在在DELETE FROM之后立即放置一个表,并在DELETE和表的一小部分自连接中放置Where限制。

DELETE from TABLE1
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 TABLE2 r0
       INNER JOIN TABLE1 r1 on r0.x = r1.x
       INNER JOIN TABLE1 r2 on r0.x = r2.x
       WHERE r1.y = foo and r2.y = bar
    ) as A  WHERE A.RANK > 1
   )