Answer the question
In order to leave comments, you need to log in
PostgreSQL throws an error that it doesn't know the generic expression. What's wrong?
Others!
Help me please.
Essence: there is a certain DB in which there is a table without primary key and numbering of lines.
There are duplicate rows in this table.
It is necessary to write a sql query that would remove duplicates.
The work is being done in Postgresql, version 11.9.
After searching the Internet, I came across this article:
https ://vc.ru/dev/134435-sposoby-udaleniya-dublika...
in our case, the table does not have a primary key, the second option was chosen, namely through the ROW_number () window function.
Here is an example of my code:
WITH D AS
(
select s.*,
row_number () over (Partition by s.*
) as numbering
from sales s
)
delete FROM D
WHERE numbering > 1;
After that, Postgre throws the following error: "ERROR: ERROR: relation "d" does not exist
LINE 8: delete FROM D"
Although if you try to select this generic expression, there are no errors.
WITH D AS
(
select s.*,
row_number () over (Partition by s.*
) as numbering
from sales s
)
select * from D
Can you please tell me what is causing this error?
I'm still quite new to this.
Thank you all in advance :)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question