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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:13:34+00:00 2026-06-06T15:13:34+00:00

I have a table (call it table myTable). It has the data like this:

  • 0

I have a table (call it table myTable).

It has the data like this:

number / name

1    jake
2    chris
3    sally
4    billy
1    tom
5    cathy

(I realize this is a poor setup, but I didn’t get the luxury of doing the setup)



I need to query this table so that the results are returned with:

1    jake
2    chris
3    sally
4    billy
5    cathy

OR

2    chris
3    sally
4    billy
1    tom
5    cathy


It does not matter which name gets returned for the duplicated number… only that ONE gets returned.

Here is my not-working attempt:

with
a as (
      SELECT number
      FROM myTable
),

b as (
      SELECT number, name
      FROM myTable
)


SELECT a."number", b."name"

FROM a
left join b on a."number" = b."number"
  • 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-06-06T15:13:37+00:00Added an answer on June 6, 2026 at 3:13 pm

    Use GROUP BY to ensure that each number is only returned once, and use an aggregate function to pick one of the values for name:

    SELECT number, MAX(name) AS name
    FROM yourtable
    GROUP BY number
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table (call it my_table ) that can be simplified like this: NAME,
My situation is this: We have a superclass, MyAbstractEntity @Entity @Table(name = MyTable) @Inheritance(strategy
I have a table, call it MyTable which has a column, say myvalue. I
I have my table: call it tblA THis table has three rows, id ,
I have strings like Name:, Call:, Phone:....and so on in my table. I am
I have a table, let's call is [MYTABLE] , with an FOR INSERT, UPDATE
I have a simple table (lets call it Table1) that has a NVARCHAR field
I have a table in mysql, let's call it foo and it has a
My table has many row that have a same column. I'll call the column
I have a table, let's call it My_Table that has a Created datetime column

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.