Skip to content
Advertisement

Postgres giving relation does not exist error for alias

Above query is working fine in MS Sql but showing this error when running it in postgres

Advertisement

Answer

In MS Sql Server it’s possible to update the CTE.

In Postgresql you can link to a CTE for an update.

For example:

However, such update assumes that the id in that table is unique.

But, to mark the newest duplicates it can be simplified.

Or if you want to flag the higher amounts.
Using ROW_NUMBER could help.

Test on db<>fiddle here

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement