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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:45:36+00:00 2026-06-09T12:45:36+00:00

I have a legacy table whos data I have to migrate to a new

  • 0

I have a legacy table whos data I have to migrate to a new structure. In the old structure each row represesnts an year, having fields for each month. In the new one each row will represent a month. The old structure is :

OLD_TABLE (
id1,
id2,
    year,
price01,
price02,
price03,
price04,
...
price11,
price12,
quantity01,
quantity02,
quantity03,
...
quantity11,
quantity12,

) -> PK = id1,id2,year

the new structure is like this :

NEW_TABLE (
id1,
id2,
year,
month,
quantity,
price,

) -> PK = id1,id2, year

Any advices on how should i proceed in migrating data from the old structure to the new one?

Thank you!

  • 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-09T12:45:37+00:00Added an answer on June 9, 2026 at 12:45 pm

    If you are using 11g or later, look at the unpivot syntax

    Something like…

    SELECT *
    FROM yourtable
    UNPIVOT (price FOR pmonth IN (price01 AS 1, price02 AS 2...))
    UNPIVOT (quantity FOR qmonth IN (quantity01 AS 1, quantity02 AS 2...))
    WHERE pmonth=qmonth
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new rails app which needs to access data from a legacy
Let's say I have a legacy MySQL table called server with fields serverid:integer and
i have a legacy db structure like table t1 ( c0 bigint, // pk
I have the old legacy table called DXFTACCTS, and I created Rails model Account.
I have a legacy MS Access 2007 table that contains 52 fields (1 field
I am new to NH. I have a table in a legacy DB that
I have a legacy data table in SQL Server 2005 that has a PK
I have a (legacy) table with two guid fields. The second guid field can
I have a legacy table, which I can't change. The values in it can
I have a table which has essentially boolean values in a legacy database. The

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.