Search code examples
sqlms-accessms-access-2010unionunpivot

Unpivot Data Using MS Access Query


Hoping someone with Access & SQL experience would be able to write some SQL code that I could use in MS Access to transform/unpivot some data. I've spent a day trying advise from others who have asked similar questions here, but I have no SQL experience and have failed miserably so far.

Image


Solution

  • You can use union all to unpivot in access:

    select item, 'A' as period, a as forecast from tbl_weekly_forecast
    union all select item, 'B', b from tbl_weekly_forecast
    union all select item, 'C', c from tbl_weekly_forecast
    union all select item, 'D', d from tbl_weekly_forecast