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 8480507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:18:47+00:00 2026-06-10T19:18:47+00:00

I am using MS SQL 2008R2. I am working with a partial data set

  • 0

I am using MS SQL 2008R2. I am working with a partial data set (i.e. not all colunms) and have not been able to exclude duplicate rows. For example, here are the rows for a claim:

Claim       Line Doctor Received    Paid
02195111345 1    22924  1995-11-13  2001-10-02  
02195111345 1    22924  1995-11-13  2001-10-02  
02195111345 2    22924  1995-11-13  2001-10-02  
02195111345 2    22924  1995-11-13  2001-10-02  
02195111345 3    22924  1995-11-13  2001-10-02  
02195111345 3    22924  1995-11-13  2001-10-02  
02195111345 4    22924  1995-11-13  2001-10-02  
02195111345 4    22924  1995-11-13  2001-10-02  
02195111345 5    22924  1995-11-13  2001-10-02  
02195111345 5    22924  1995-11-13  2001-10-02  

I want to select only 1 row for each Claim+Line. There are additional columns, but they contain the same information for each combination of Claim+Line.

I can easily identify the rows with duplicates with a query such as:

SELECT [ClaimNum],[ClaimNum_Line]
FROM [dbo].[DamagedClaims]
GROUP BY [ClaimNum],[ClaimNum_Line]
HAVING COUNT(*) > 1 

Typically, I would create a derived table using this query and join it back to the table – with another coulmn such as MAX(Version) or such, but there are no such columns with which to differentiate the duplicates.

I have considered

SELECT ClaimNum], Line, MAX(DOCTOR), MAX([Date Received]), MAX([Date Paid])

but there are about 20 columns and 750 million rows and that seemed like a lot of overhead (I am very sympathetic to our SQL Servers!). Is there a better solution?

Best,
Scott

  • 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. Editorial Team
    Editorial Team
    2026-06-10T19:18:48+00:00Added an answer on June 10, 2026 at 7:18 pm

    just add DISTINCT in your SELECT

    SELECT DISTINCT Claim, Line, Doctor, Received, Paid
    FROM tableName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server 2008R2 fetching data between two dates is not working. I am
I'm working with sql server 2008r2 developer. I have a stored procedure that adds
I am new so please be gentle. Been using SQL server 2008r2 to create
I have a query which I'm using with SQL Server 2008R2 via ADO.NET. When
I have a working database application using WPF and SQL Server 2008 R2, which
I have been working on ASP.net MVC3 Web application using MSSQL 2008 R2 for
I am using SQL Server 2008r2. I have a table with a column defined
I am using SQL Server 2008 R2, I have a script to update the
Hi i am using SQL Server 2008 R2, i have lots of procedures in
I am using SQL Server 2008 R2, and I have created a schema Test

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.