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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:19:40+00:00 2026-05-21T03:19:40+00:00

Guys, I’m new at SQL and can’t figure out the right way to do

  • 0

Guys, I’m new at SQL and can’t figure out the “right way” to do the last part of a query. I have a table which contains a list of items and their equivalents. There are essentially twice as many rows as needed, and I’m trying to find a SQL way to select 1/2 of the entries so there are no duplicates.

Starting Table with duplicates:

Item   Name     EquivItem
----   ------   ---------- 
100    bubba    106
103    gump     109
106    shrimp   100
109    grits    103

And the resulting table would be:

Item   Name     EquivItem
-----  -----    ----------
100    bubba    106
103    gump     109

I was using a couple nested loops in sequential code to filter out the duplicates, but finally wrote a query that works but feels like a hack.

I’m arbitrarily using a WHERE (Item < EquivItem) to select only one of the rows. The actual tables are a bit more complex and I’m afraid there may be a case where this doesn’t work.

SELECT *
FROM T
WHERE Item < EquivItem

I’m trying to take some time to figure out the right way to do things before I develop too many bad habits. Any suggestions? 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-21T03:19:40+00:00Added an answer on May 21, 2026 at 3:19 am

    Is it possible for more than two items to be equivalent, such as 100 = 103 = 106? Can this happen?

    Item   Name     EquivItem
    ----   ------   ---------- 
    100    bubba    103
    103    gump     106
    106    shrimp   103
    

    As long as the the equivalents can’t be chained together, and always have a 1-to-1 relationship, your solution looks perfectly fine to me.

    If this scenario can happen, I would first scrub the data to make sure that all the EquivItems refer to the lowest Item ID in the chain… and then your original query would still do the job.

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

Sidebar

Related Questions

Guys can you suggest me any software who have some similarities with Microsoft's SQL
Guys i m having a table in which i have gender and date columns
Guys I have an activity which has a home button, when the button is
guys i have a xml file which is like this: <Point TestFlag=0 id=1 name=Conversation
guys, I have iOS app, which running good on ios5.0, but on 4.3.3 it's
Guys i have a textview which i need it to be blinking please help
Guys, I am very new to c++. I have just wrote this class: class
Guys, I have been surfing thru the web to find a way that I
guys. I have UITableView with different cells and I have code, which counts height.
guys How can i achieve the following var productslist=from p in productsTable select new

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.