Solved

Delete the duplicate record, but based on the contents of two fields.

Posted on 2013-01-21
3
587 Views
Last Modified: 2013-01-22
HI!
When only the contents of one field defines which record is duplicated, I know to create the phrase  SQL to delete.
But in this case, not.
Because, I need to delete the duplicate record, but based on the contents of two fields in the table.
When the two fields together, repeat content.

Example:
 Field1 and  Field2

2345|456|->keep
2346|358|->keep
2347|234|->keep
2347|675|->keep
2347|456|->keep
2347|456|------>delete
2347|456|------>delete
2347|432|->keep
2348|432|->keep

Can anyone help me by writing a sample in SQL?
Please use only standard SQL commands.
Because DB is to use the Firebird, and all DBs perform  standards commands.
Thank you very much.
0
Comment
Question by:adrex
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38804061
try this .. t is your tablename

TABLE tmp AS SELECT DISTINCT(t.Field1,t,Field2), * FROM t;
DROP TABLE t;
ALTER TABLE tmp RENAME TO t;

refer
http://stackoverflow.com/questions/1746213/how-to-delete-duplicate-entries-in-postgresql
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38804075
try this also

using single query

http://wiki.postgresql.org/wiki/Deleting_duplicates
0
 

Author Comment

by:adrex
ID: 38806780
pratima_mcs
From your example. I got to formulate a solution.
Same I was far more extensive than yours.
And your example uses command incompatible with the Firebird, but I got to make replacement by equivalents.
It worked.
Thank you.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now