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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:19:02+00:00 2026-06-12T00:19:02+00:00

I have few columns in a table Col1 , Col2 , Col3 , Col4

  • 0

I have few columns in a table

Col1, Col2, Col3, Col4

Now I want to select like this

SELECT DISTINCT (Col1, Col2, Col3), Col4

i.e. get the distinct based on only these three colunms.

  • 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-12T00:19:03+00:00Added an answer on June 12, 2026 at 12:19 am

    From a comment to another answer:

    Can I get like this Col1, Col2 , Col3 and (Col4 in delimiter form)

    Yes, you can use the for xml path.

    select Col1, 
           Col2,  
           Col3, 
           (
            select ',' + T2.Col4
            from YourTable T2
            where T1.Col1 = T2.Col1 and
                  T1.Col2 = T2.Col2 and
                  T1.Col3 = T2.Col3
            for xml path(''), type
           ).value('substring((./text())[1], 2)', 'varchar(max)') as Col4
    from YourTable as T1
    group by T1.Col1, T1.Col2, T1.Col3
    

    SQL Fiddle

    • 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 few million records. ___________________________________________________________ | col1 | col2 |
I have a HTML table and I want the first few columns to be
I have a query in VBA that Adds a few columns to a table.
I have a table with few columns and one of the column is DockNumber.
I have a table which consists of a few columns, including a Key Value
I have a table, tblDocs that has a few columns: DocName varchar(50) DocLocation int
I have a table with a few thousand rows. The table contains two columns,
I have a few tables with 70-80 columns in them. I would like to
I have a table in MySQL that have a few columns that have default
I have a few columns in a table that are added to my publication

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.