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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:54:49+00:00 2026-06-07T17:54:49+00:00

So the question is this. I have a table with n columns of data,

  • 0

So the question is this. I have a table with n columns of data, but I want to list one row for each unique set of 3 columns.

For example, say the table is structured as below

ID | data1 | data2 | data3 | description | price | handler | creationTime | etc...

What I’m trying to do, is to use this subquery:

SELECT distinct data1, data2, data3 FROM Table_1

… to get each unique variation for the 3 columns. But then I want to select ONE full row from the table for each such result.

This query is meant for rather heavy use and needs to be optimized, which is kind of why I can’t use table variables or while loops. Any hints?

  • 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-07T17:54:51+00:00Added an answer on June 7, 2026 at 5:54 pm

    if you are using SQL Server, you can do this with a common table expression:

    with minRow(ID) as 
        (select min(ID)
        from    Table_1
        group by data1, data2, data3)
    select  t1.*
    from    Table_1 t1 join minRow m1 on t1.ID = m1.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this time i have a simple question: I have one table, related with himself
I have (simplified for this question) a table 'TAB' with two columns 'id' (integer
I have a table which is currently displayed like this: Question OptionType What is
I have a table like this, with three fields: User | Question# | Answer
This question is along the lines of HTML table horizontal spacing We have an
i have a table which looks similar to this <asp:TableRow><asp:TableCell>Question 1</asp:TableCell><asp:TableCell ID =Question1Text></asp:TableCell></asp:TableRow> <asp:TableRow><asp:TableCell
A newbie question,really. Suppose I have a html table like this: <div id=div1> <table
I have a question. My database table is something like this: | ID |
I just saw this dating site on builtwithbootstrap and have a question about table
Question: I have to create a tablet application. In this i want to make

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.