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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:13:08+00:00 2026-05-28T16:13:08+00:00

I currently have a customers table that has duplicate customers in it. I want

  • 0

I currently have a customers table that has duplicate customers in it. I want to select a unique list of customers, with no duplicates of home phone OR cell phone.

So, if any customer has the same home phone or cell phone as another customer then, I want to not return that customer from the query.

One caveat — if homephone or cellphone is empty, then I obviously do not want to count it in the anti-duplicate logic, because some customers only have a homephone, or only have a cellphone.

Here is the current query that I have, which returns unique rows for homephone AND cellphone.

SELECT id, firstname, lastname, homephone, cellphone, city, state, zip, 
country, FROM customers WHERE (homephone != "" OR cellphone != "")
GROUP BY homephone, cellphone

Any ideas? Thanks.

  • 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-28T16:13:09+00:00Added an answer on May 28, 2026 at 4:13 pm

    You have to funnel all phone numbers into the one evaluation and sort/group by that.

    Try this:

    SELECT id, firstname, lastname, homephone, cellphone, city, state, zip, country
    FROM customers
    WHERE homephone != '' OR cellphone != ''
    GROUP BY case when homephone = '' then cellphone else homephone end
    

    It will get the first row found for every unique value of “homephone, but if blank then cellphone”

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

Sidebar

Related Questions

Good afternoon I have a table that has customer id, name, computer, laptop, blah,
We have an install that is currently running Magento CE v1.5 (it has been
I have a customer table that I want to use to populate a parameter
We currently have one table that stores information about what the customer owes us.
We have a database that has been deployed to various clients. We are currently
I have a table that links my customers to DVDs they have checked out.
I have a list<> of phone numbers and I am trying to join that
I have a profit and loss report that currently has three levels of grouping:
I have a customer table where I'm currently storing: Last Name First Name Middle
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers

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.