I have a query like this which is working well on postgresql server;
SELECT *
FROM
(SELECT s_o_i,
row_number() OVER (PARTITION BY g_i,
c
ORDER BY o_s DESC) AS rank
FROM b_o) b_o
WHERE rank > 1
AND m_t < CURRENT_DATE - interval '1 months'
When I convert this to this query;
DELETE
FROM
(SELECT s_o_i,
row_number() OVER (PARTITION BY g_i,
c
ORDER BY o_s DESC) AS rank
FROM b_o) b_o
WHERE rank > 1
AND m_t < CURRENT_DATE - interval '1 months'
It throws an error like this;
ERROR: syntax error at or near "("
LINE 3: (SELECT s_o_i,
why does it throw an error on delete query?
DELETE
FROM
(SELECT s_o_i,
row_number() OVER (PARTITION BY g_i,
c
ORDER BY o_s DESC) AS rank
FROM b_o) b_o
WHERE rank > 1
AND m_t < CURRENT_DATE - interval '1 months'
I expect it to run and delete the records on the clauses.
rankvalue to delete the records.rankwith that