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

  • Home
  • SEARCH
  • 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 7703691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:31:00+00:00 2026-05-31T23:31:00+00:00

This question does pretty much what I want to accomplish, but my table is

  • 0

This question does pretty much what I want to accomplish, but my table is more complicated and does not have a primary key. I also don’t quite understand the top answer, what the t1 and t2 mean. If this answer can be applicable to me, would appreciate if someone explain the code.

I have several months’ tables that contain info on clients and the policies they hold. Every client has a unique policy ID, but they can have multiple policies, resulting in multiple records under the same policy ID. The duplicate records can be completely different or exactly the same in every field.

For my purposes, I want to keep only one record for each policy ID. Ideally the record kept is the one with the highest Age, but does not need to if it’s too complicated. Note there may be more than one record with the age that is the max for that particular Policy ID, then it doesn’t matter which one of those we keep.

I do not plan on creating a primary key because there are some cases when I will be keeping two records under the same policy ID, which I will make the modification to the code myself. I also don’t want to create another table because I am working with 10+ tables. Someone suggested using first(), but I’m not sure how to incorporate it into a query.

Please let me know if you need any additional information, and thank you for your help in advance!

=========UPDATE #1

Okay, looks like my question was a bit unrealistic, so I will add an autonumber primary key. How will I proceed with that?

  • 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-05-31T23:31:01+00:00Added an answer on May 31, 2026 at 11:31 pm

    Something on these lines:

    DELETE Policies.*
    FROM Policies
    WHERE Policies.ID Not In (
       SELECT TOP 1 id
       FROM   policies p
       WHERE  p.policyid = policies.policyid
       ORDER  BY createdate DESC, id )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spotted this question: Does Microsoft SkyDrive have an API? But not having an
I read this question but the answer does not perform a refactoring of the
(This question does not rely on a specific IoC framework, so the interfaces and
The manual does not answer this question : it says the name of the
Started with this question: OpenID. How do you logout OK. So OpenID does not
Or say does 1 denotes white for an RGB image? I have this question
I have a model pretty much like this: Document Release has an embedded array
This is somewhat related to another question that I've asked that I've pretty much
The question I want to ask is about XML namespaces. Pretty much everytime I
This question is spawned from the partial answer to JSF2: why does empty 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.