test

0

Please login or register to vote for this query.

(click on this box to dismiss)

Arts and Crafts Meta

Q&A about the site for artists and crafters

CREATE table #yourtable
    ([Id] int, [CalculationName] varchar(20), [TimeStamp] datetime, [Smelter Production - Daily Snapshot] decimal)
;
    
INSERT INTO #yourtable
    ([Id], [CalculationName], [TimeStamp], [Smelter Production - Daily Snapshot])
VALUES
    (1, 'CabledIngotsTotal', '2021-11-18 07:15:00.000', 34),
    (2, 'TotalPadBay', '2021-11-18 07:15:00.000', 86),
    (3, 'Edison Max', '2021-11-18 07:15:00.000', 12),
    (4, 'Edison Avg', '2021-11-18 07:15:00.000',45),
    (5, 'FurnaceResult ', '2021-11-18 07:15:00.000', 57),
    (6, 'CabledIngotsTotal', '2021-11-17 07:15:00.000', 66)
;


SELECT  [TimeStamp], 
        [CabledIngotsTotal],
        [TotalPadBay], 
        [FurnaceResult], 
        88 [TARGET1], 
        99 [TARGET2]
FROM
(
  SELECT [TimeStamp], 
         [Smelter Production - Daily Snapshot], 
         [CalculationName]
  FROM #yourtable
) d
PIVOT
(
  MAX([Smelter Production - Daily Snapshot])
  FOR [CalculationName] IN ([CabledIngotsTotal], [TotalPadBay], [FurnaceResult])
) piv;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results