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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:26:27+00:00 2026-05-31T21:26:27+00:00

How to convert table from this format: Id | Data |Section —————————————— 1 |1AAA

  • 0

How to convert table from this format:

Id | Data           |Section
------------------------------------------
1  |1AAA            |AAA
------------------------------------------
1  |1BBB            |BBB
------------------------------------------
1  |1CCC            |CCC
------------------------------------------
2  |2AAA            |AAA
------------------------------------------
2  |2BBB            |BBB
------------------------------------------
2  |2CCC            |CCC
------------------------------------------
3  |3AAA            |AAA
------------------------------------------
3  |3CCC            |CCC
------------------------------------------

To this format with T-sql ?

Id |Column_AAA|Column_BBB|Colunm_CCC|
-------------------------------------
1  |1AAA      |1BBB      |1CCC      |   
-------------------------------------
2  |2AAA      |2BBB      |2CCC      |       
-------------------------------------
3  |3AAA      |.....     |3CCC      |   
  • 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-31T21:26:28+00:00Added an answer on May 31, 2026 at 9:26 pm

    this should give you the results you want.

    CREATE TABLE #temp
    (
        id int,
        data varchar(50),
        section varchar(50)
    )
    insert into #temp values(1, '1AAA', 'AAA')
    insert into #temp values(1, '1BBB', 'BBB')
    insert into #temp values(1, '1CCC', 'CCC')
    insert into #temp values(2, '2AAA', 'AAA')
    insert into #temp values(2, '2BBB', 'BBB')
    insert into #temp values(2, '2CCC', 'CCC')
    insert into #temp values(3, '3AAA', 'AAA')
    insert into #temp values(3, '3BBB', 'BBB')
    insert into #temp values(3, '3CCC', 'CCC')
    
    select id, [AAA] as Column_AAA, [BBB] as Column_BBB, [CCC] as Column_CCC
    from 
    (
        select id, data, section
        from #temp
    ) x
    PIVOT
    (
        max(data)
        FOR section IN([AAA], [BBB], [CCC])
    ) as p
    
    drop table #temp
    

    Results:

    id  column_AAA column_BBB   column_CCC
    1   1AAA        1BBB        1CCC
    2   2AAA        2BBB        2CCC
    3   3AAA        3BBB        3CCC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem while selecting from a table containg data in utf-8 format
I've got exception about convert NULL to Int32. I've got a table from database
Using PHP, I can convert MySQL data or static table data to csv, Excel,
Im trying to copy over data from one table to another in the same
I have a php query the returns the following JSON format from a table.
I have this old Access database (2000 format) which i want to convert to
I have data in a mysql table in long / tall format (described below)
Step 1: Loading data via bulk insert from .txt (delimited) file into Table 1
Is there any guidelines to convert Table design to Div design keeping same cross
What is the best optimized way to convert table base design to table less

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.