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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:43:45+00:00 2026-06-15T21:43:45+00:00

The table contains numerous rows for the same person and all columns contain the

  • 0

The table contains numerous rows for the same person and all columns contain the same data. For Instance:

FullName       Gender     DOB
---------------------------------
Mary Jones     Female     2012-05-01

I would like to select one row for each individual to appear in a report. I thought the easiest way might be to us an if statment to check if the next row is the same as the first unique row.

  • 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-15T21:43:47+00:00Added an answer on June 15, 2026 at 9:43 pm

    As others have said, since all the rows are the same you can use the distinct keyword:

    SELECT DISTINCT <columns>
    FROM table
    

    However, you’re likely to find that the reason for these duplicate records is that at least one column somewhere in the table is different. In that case, you may need to use GROUP BY instead:

    SELECT <columns>
    FROM table
    GROUP BY <columns>
    

    If you need to show data that is not part of the grouped columns, you only list the columns that match in the GROUP BY clause and then you have to use an aggregate function or sub query to bring data from the unique columns into the select list. GROUP BY queries can get really complex and make your head hurt.

    If the columns really are consistently the same, something in your schema or application design isn’t right. It’s rare that you should ever have truly duplicate records in a table, and it’s more likely to mean something is wrong.

    Finally, I need to comment about your IF/THEN request. This idea is way off. SQL has a SET-based or declarative programming style. Thinking about problems using procedural tools like IF/THEN will only lead to trouble. Even if you really do need a conditional expression, the way to do it within an SQL statement is via a CASE expression.

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

Sidebar

Related Questions

I have a table with a few thousand rows. The table contains two columns,
A table contains four columns server, directory, usage and datetime. All servers has got
my table contains category_name and parent_category_Id column My parent_category data contains, the same table
Using SQL2k5, I have a staging table that contains columns that will populate numerous
I have 2 columns, name1 and name2, that contain numerous rows of possible names.
Settings table contains always one row with lot of long-caption columns. Opening this in
create table foo (id int(11) auto_increment, value varchar(255)) The table contains roughly 10,00,000 rows
I've got a question regarding a SQL-select-query: The table contains several columns, one of
User table contains the following attributes (dateOfBirth, race, gender, ...). We would like to
The table contains 4 columns: id (autoincrement), userid (unique, like ssn), status (TINYINT(1), 0

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.