Priscila Estala Priscila Estala - 6 months ago 9
SQL Question

Transpose Table with information

I need to transpose this view (in sql)

enter image description here

into this view:

enter image description here

any solutiion?

Answer

You can use union all:

select location, planning_product, '2016-05-16' as MondayDate, "5/16/2016" as ROP
from t
union all
select location, planning_product, '2016-05-09' as MondayDate, "5/9/2016" as ROP
from t
union all
. . .

Note that the column names need to be escaped. Some databases uses double quotes, others use backticks or square braces.