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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:31:09+00:00 2026-05-19T01:31:09+00:00

I have a table in my database which stores packing slips and their information.

  • 0

I have a table in my database which stores packing slips and their information. I’m trying to query that table and get each unique address. I’ve come close, but I still have many near misses and I’m looking for a way to exclude these near duplicates from my select.

Sample Data

CompanyCode   CompanyName                     Addr1                City         State   Zip
10033         UNITED DIE  CUTTING & FINISHIN  3610 HAMILTON AVE    CLEVELAND    Ohio    44114
10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVE    CLEVELAND    Ohio    44114
10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVE.   CLEVELAND    Ohio    44114
10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVENUE CLEVELAND    Ohio    44114
10033         UNITED DIECUTTING & FINISHING   3610 HAMILTON AVE    CLEVELAND    Ohio    44144
10033         UNITED FINISHING                3610 HAMILTON AVE    CLEVLAND     Ohio    44114
10033         UNITED FINISHING & DIE CUTTING  3610 HAMILTON AVE    CLEVELAND    Ohio    44114

And all I want is 1 record. Is there some way I can get the “Average” record? Meaning, if most of the records say CLEVELAND instead of CLEVLAND, I want my 1 record to say CLEVELAND. Is there any way to par this data down to what I’m looking for?

Desired Output

 CompanyCode   CompanyName                     Addr1                City         State   Zip
 10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVE    CLEVELAND    Ohio    44114
  • 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-19T01:31:10+00:00Added an answer on May 19, 2026 at 1:31 am

    You need to use subqueries in the select statement
    Try this query:

     select CompanyCode,
        (select top 1 CompanyName from Table1 where CompanyCode=X.CompanyCode 
         group by CompanyName order by count(*) desc) CompanyName,
        (select top 1 Addr1 from Table1 where CompanyCode=X.CompanyCode 
         group by Addr1 order by count(*) desc) Addr1,
        (select top 1 City from Table1 where CompanyCode=X.CompanyCode 
         group by City order by count(*) desc) City,
        (select top 1 State from Table1 where CompanyCode=X.CompanyCode 
         group by State order by count(*) desc) State,
        (select top 1 Zip from Table1 where CompanyCode=X.CompanyCode 
         group by Zip order by count(*) desc) Zip
    from    Table1 X
    group by CompanyCode
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table called Posts which stores all the information regarding an
I have a table in my database which stores a tree structure. Here are
I have a database structure that has a Person table which contains fields such
I have many tables in my database which are interrelated. I have a table
I have a string column in a database table which maps to an Enum
I have a database table (named Topics) which includes these fields : topicId name
I have an Access database in which I drop the table and then create
In a SQL server database, I have a table which contains a TEXT field
I have a database with a table which is full of conditions and error
I have a database (NexusDB (supposedly SQL-92 compliant)) which contains and Item table, a

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.