0

I'm new to SQL. I tried to delete the duplicate customer record where has same name and surname. This below is my command

delete duplicated_records from  (
  select row_number() over (partition by name, surname
                            order by name, surname) as rn
      ,          * 
  from customer
) duplicated_records where rn > 1;

Which throw me this error

ERROR:  syntax error at or near "duplicated_records"
LINE 1: delete duplicated_records from  (

But when I tested running just to see the record, I didn't get any error.

select duplicated_records from  (
  select row_number() over (partition by name, surname
                            order by name, surname) as rn
      ,          *
  from customer
) duplicated_records where rn > 1;

Could anyone please advise me if I did something wrong here. Thanks in advance.

3
  • Check your syntax: DELETE FROM table_name WHERE condition; Commented Oct 22, 2020 at 8:52
  • @iLuvLogix in this case, could you please guide me what's I should change my command to? Thanks Commented Oct 22, 2020 at 9:07
  • 3
    Does this answer your question? PostgreSQL Removing duplicates Commented Oct 22, 2020 at 9:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.