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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:39:25+00:00 2026-05-28T01:39:25+00:00

I am having a table with following schema: CUSTOMERS (id INT, name VARCHAR(10), height

  • 0

I am having a table with following schema:

CUSTOMERS (id INT, name VARCHAR(10), height VARCHAR(10), weight INT)

id is the primary key. I want to find out rows in which people who are having exactly same name, same height and same weight. In other words, I want to find out duplicates with-respect-to name, height and weight.

Example table:

1, sam, 160, 100
2, ron, 167, 88
3, john, 150, 90
4, sam, 160, 100
5, rick, 158, 110
6, john, 150, 90
7, sam, 166, 110

Example Output:

Now since there are people with same name, same height and same weight:

sam (id=1), sam (id=4)

and

john (id=3), john (id=6)

I want to get these ids. It is also okay if I get only one id per match (i.e. id=1 from first match and id=3 from second match).


I am trying this query but not sure if it is correct or not.

SELECT id
FROM customers
GROUP BY name, height, weight
  • 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-28T01:39:26+00:00Added an answer on May 28, 2026 at 1:39 am

    Try this (valid for sql server):

    SELECT 
        t.NAME,
        'Ids = '+
        (
            SELECT cast(Id as varchar)+',' 
            FROM Customers c 
            WHERE c.NAME = t.NAME AND c.Weight = t.Weight AND c.Height = t.Height
            FOR XML PATH('')
        )
    FROM
    (
        SELECT Name, height, weight
        FROM Customers
        GROUP BY Name, height, weight
        HAVING COUNT(*) > 1
    ) t
    

    OR

    as you asked – only one Id per match

    SELECT 
        t.NAME,
        c.Id
    FROM
    (
        SELECT Name, height, weight
        FROM Customers
        GROUP BY Name, height, weight
        HAVING COUNT(*) > 1
    ) t
    JOIN Customers c ON t.NAME AND c.Weight = t.Weight AND c.Height = t.Height
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having the following table schema: tablename( name varchar[100], age int, sex char[1] ) Having
My SQL schema is CREATE TABLE Foo ( `bar` INT NULL , `name` VARCHAR
i m having following type of simple sql server table Here I want to
Having the following table schema: id | english_name | russian_name | year --------------------------------------- 5
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I'm Working with a new Oracle DB, with one table having the following indexes:
Given the following html table and script shown below I am having a problem
I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
I'm having the following two tables... Table : room_type type_id type_name no_of_rooms max_guests rate
I have 3 columns in Oracle database having table mytable and i want records

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.