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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:43:08+00:00 2026-05-19T02:43:08+00:00

wasn’t sure whether to put this in Software or here, so I figured I’d

  • 0

wasn’t sure whether to put this in Software or here, so I figured I’d start here I know this will be a straightforward answer from you SQL geniuses…

I have a table, it contains contacts that I import on a daily basis. I will have an ASP.NET front end for user interaction. From this table, my intention is to send them all mailers – but only one to each address. So my end result is a user enters a date (which corresponds to teh date imported) and they are given a resultant grid that has all the unique addresses associated to that date. I only want to send a mailer to that address once – many times my original imported list will contain multiple businesses at the same address.

Table: ContactTable
Fielsd:
ID, CompanyName, Address, City, State, Zip, Phone

I can use the SELECT DISTINCT clause, but I need all the data associated to it (company name, etc.)

I have over 262000 Records in this table.

If I select a sample date of 1/10/2011, I get 2401 records. SELECT DISTINCT Address from the same date gives me 2092 records. This is workable, I would send those 2092 people a mailer.

Secondly, I’d have to be able to historically check if a mailer was already sent to that address as well. I would not want to send another mailer to the same business tomorrow either.

What’s my best way?

  • 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-19T02:43:08+00:00Added an answer on May 19, 2026 at 2:43 am

    I would select, then remove, the duplicates like this:

    SELECT  a.ID, a.PurgedID, a.CAMPAIGNTYPE, a.COMPANY, a.DBANAME, a.COADDRESS, a.COCITY, a.COSTATE, a.COZIP, a.FIRSTNAME1, a.DIALERPHONENUM, a.Purged FROM PurgeReportDetail a
    WHERE EXISTS (
        SELECT * FROM PurgeReportDetail b WHERE
        b.COADDRESS = a.COADDRESS
        AND b.COCITY = a.COCITY
        AND b.COSTATE = a.COSTATE
        AND b.COZIP = a.COZIP
        AND b.id <> a.id
        ) -- This clause will only include rows with duplicate columns noted
    AND a.ID IN (
        SELECT TOP 1 c.ID from PurgeReportDetail c 
        WHERE c.COADDRESS = a.COADDRESS
        AND c.COCITY = a.COCITY
        AND c.COSTATE = a.COSTATE
        AND c.COZIP = a.COZIP
        ORDER BY c.ID -- If you want the *newest* entry to be saved, add "DESC" here
        ) -- This clause gets the top 1 ID value for each matching set
    

    or something like this.
    This will keep the first ID of the redundant address, just replace the SELECT with DELETE when ready.

    EDIT: Of course this will only work on exact matches.

    EDIT2: If you wanted to only check where you hadn’t sent mailers, you should join both to a table of sent mailers from a specified date range

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a C++ newbie, but I wasn't able to find the answer to this
I wasn't able to find an answer anywhere about this seemingly simple topic: is
I wasn't really sure how to phrase the name of this thread, so if
I wasn't even sure how to phrase this so you'll have to forgive me
I wasn't sure of the title, but I hope you will be able to
I wasn't sure how to word this question, so i'll just explain. I want
Hope the title isn't to confusing wasn't sure how I should put it. I
I wasn't sure how to call this. Basically I have a Label widget. It
This wasn't immediately clear to me from the docs for QCoreApplication::quit() . Are any
Mac Store wasn't released yet, but I know that are experienced mac programmers here

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.