I have this table below

How do I make the output like this

I did the output above using this query:
SELECT DISTINCT
C.RefVal,
C.CalibrationEventID,
C1.Result As "Trial One",
C2.Result AS "Trial Two",
C3.Result AS "Trial Three",
C4.Result AS "Trial Four",
C5.Result AS "Trial Five"
FROM CalibrationTrials AS C
INNER JOIN
(SELECT DISTINCT RefVal, Result FROM CalibrationTrials WHERE CalibrationEventID = 'CAL000001' AND RefVal = '1.0010'AND TrialNo = 1) As C1
ON C1.RefVal = C.RefVal
INNER JOIN
(SELECT DISTINCT RefVal, Result FROM CalibrationTrials WHERE CalibrationEventID = 'CAL000001' AND RefVal = '1.0010'AND TrialNo = 2) As C2
ON C2.RefVal = C.RefVal
INNER JOIN
(SELECT DISTINCT RefVal, Result FROM CalibrationTrials WHERE CalibrationEventID = 'CAL000001' AND RefVal = '1.0010'AND TrialNo = 3) As C3
ON C3.RefVal = C.RefVal
INNER JOIN
(SELECT DISTINCT RefVal, Result FROM CalibrationTrials WHERE CalibrationEventID = 'CAL000001' AND RefVal = '1.0010'AND TrialNo = 4) As C4
ON C4.RefVal = C.RefVal
INNER JOIN
(SELECT DISTINCT RefVal, Result FROM CalibrationTrials WHERE CalibrationEventID = 'CAL000001' AND RefVal = '1.0010'AND TrialNo = 5) As C5
ON C5.RefVal = C.RefVal
WHERE C.CalibrationEventID = 'CAL000001' AND C.RefVal = '1.0010'
ORDER BY C.RefVal, C.CalibrationEventID
Apparently with this query the output is only fixed to one RefVal which is ‘1.0010’
What would be the correct query to output image2 format for each RefVal of a CalibrationEventID?
Here’s how you can use a PIVOT clause for your query:
The above assumes that your table consists only of columns
RefVal, CalibrationEventID,. If there are more columns in the table, you should first select these four separately, then apply PIVOT. Here:TrialNo, Result
This is needed because a PIVOT query is essentially a special case GROUP BY query. All columns except
Resulttake part in grouping implicitly. That’s why you should get rid of those that are not needed in this kind of grouping.And here’s an alternative approach, without PIVOT: