Reputation: 48482
I have a simple table that looks as follows:
I'm executing the following query:
SELECT
DeviceId,
[UCL],
[LCL]
FROM dbo.BreweryTemperatureSetpoint
PIVOT
(
SUM(SetpointValue) FOR SetpointName IN ([UCL], [LCL])
) AS PVT
The output looks like this:
What I would like is a single row that looks like this:
Prototype1, 24, 21.75
There is something about Pivot I don't quite understand since I would have thought my query would produce the desired output, but it isn't.
Upvotes: 1
Views: 17
Reputation: 81990
Limit the fields in the "Source" to what is needed. XAxis, YAxis and Value
SELECT *
FROM (
Select DeviceId,SetpointValue,SetpointName
FROM dbo.BreweryTemperatureSetpoint
) A
PIVOT
(
SUM(SetpointValue) FOR SetpointName IN ([UCL], [LCL])
) AS PVT
Upvotes: 2