Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:44:22+00:00 2026-05-10T21:44:22+00:00

The database type is PostGres 8.3. If I wrote: SELECT field1, field2, field3, count(*)

  • 0

The database type is PostGres 8.3.

If I wrote:

SELECT field1, field2, field3, count(*)  FROM table1 GROUP BY field1, field2, field3 having count(*) > 1; 

I have some rows that have a count over 1. How can I take out the duplicate (I do still want 1 row for each of them instead of +1 row… I do not want to delete them all.)

Example:

1-2-3 1-2-3 1-2-3 2-3-4 4-5-6 

Should become :

1-2-3 2-3-4 4-5-6 

The only answer I found is there but I am wondering if I could do it without hash column.

Warning I do not have a PK with an unique number so I can’t use the technique of min(…). The PK is the 3 fields.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:44:23+00:00Added an answer on May 10, 2026 at 9:44 pm

    This is one of many reasons that all tables should have a primary key (not necessarily an ID number or IDENTITY, but a combination of one or more columns that uniquely identifies a row and which has its uniqueness enforced in the database).

    Your best bet is something like this:

    SELECT field1, field2, field3, count(*)  INTO temp_table1 FROM table1 GROUP BY field1, field2, field3 having count(*) > 1  DELETE T1 FROM table1 T1 INNER JOIN (SELECT field1, field2, field3       FROM table1       GROUP BY field1, field2, field3 having count(*) > 1) SQ ON             SQ.field1 = T1.field1 AND             SQ.field2 = T1.field2 AND             SQ.field3 = T1.field3  INSERT INTO table1 (field1, field2, field3) SELECT field1, field2, field3 FROM temp_table1  DROP TABLE temp_table1 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer On the page load of the DetailPage use the QueryString… May 11, 2026 at 12:00 pm
  • added an answer With TCP connections for applications like Telnet there is no… May 11, 2026 at 12:00 pm
  • added an answer No, the _s functions are NOT implemented in the standard… May 11, 2026 at 12:00 pm

Related Questions

The database type is PostGres 8.3. If I wrote: SELECT field1, field2, field3, count(*)
I have a database in the following format: ID TYPE SUBTYPE COUNT MONTH 1
So I have the following user defined type in my oracle database: CREATE OR
What would be the most efficient data type to store a UUID/GUID in databases
The Database Tuning Advisor is recommending that I create a bunch of statistics in
Generally the database server is the biggest, most expensive box we have to buy
The university I work at uses Oracle for the database system. We currently have
The above error message comes up just before SQL Server marks the database as
(Not related to versioning the database schema) Applications that interfaces with databases often have
I wish to migrate the database of a legacy web app from SQL Server

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.