I am trying to import some data to Excel from a database using SQL.
I am getting the data in the following columns:
Item# Location Qty
but I would like to import it in the following format:
Item# Qty@Location1 Qty@Location2 Qty@Location3
Select Distinct item#,
CASE WHEN location="location1" THEN qty END AS QTY@Location1,
CASE WHEN location="location2" THEN qty END AS QTY@Location2,
CASE WHEN location="location3" THEN qty END AS QTY@Location3
From table1
This, however returns 3 records.Is there any way to merge these to a single row?