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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:24:57+00:00 2026-05-25T23:24:57+00:00

I have a source report which looks like Name Q1 Q2 Q3 Q4 A

  • 0

I have a source report which looks like

Name Q1 Q2 Q3 Q4
A    1  2  3  4
B    5  6  7  8
C    9  0  1  2

It has to be converted into the following format

Name Quarter Value
A    Q1      1
A    Q2      2
A    Q3      3
A    Q4      4 
and so on...

I’m using SSIS for ETL. Any pointers without using hard-coded values in the T-SQL script?

  • 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-25T23:24:57+00:00Added an answer on May 25, 2026 at 11:24 pm

    This would be a good match for UNPIVOT but unless you are willing to make this a dynamic sql statement, I don’t see any way around hardcoding the Quarters in the statement.

    SQL Statement

    SELECT  Name
            , Quarter
            , Value 
    FROM    q 
    UNPIVOT (
              Value FOR Quarter IN (Q1, Q2, Q3, Q4)
            ) u
    

    Test script

    ;WITH q (Name, Q1, Q2, Q3, Q4) AS (
        SELECT 'A', 1, 2, 3, 4
        UNION ALL SELECT 'B', 5, 6, 7, 8
        UNION ALL SELECT 'C', 9, 0, 1, 2
    )
    SELECT  Name
            , Quarter
            , Value 
    FROM    q 
    UNPIVOT (
                Value FOR Quarter IN (Q1, Q2, Q3, Q4)
            ) u
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have vb.net application which is using Vistadb with following connection string. I am
I have a data source which is pulling in event attendance information which looks
I have a Crystal report where the data source has originally been set to
I have a client application that sets some parameters and report source on a
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record
I have a source of python program which doesn't have any documentation or comments.
I have a MS Access 2007 report which is based on a query that
I have a master report which contains a lot of information and I need
I have a custom report which draws via Graphics2D , and uses a lot
I have jar files which I constructed using command jar -cf Generic.jar /java/mypackage/*.class There

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.