How to use a select pivot query to update two different tables I would like to update data in two different table however based on select query using pivot I'm unsure how to go about to do the update query.
See query I have below:
UPDATE [FuelManagementSystem].[dbo].[OpenCloseTank] SET OpenDip = 0.00, CloseDip = 0.00 WHERE WhenDate = GETDATE() AND TankID = 'BW-TK-DSL1'
UPDATE [FuelManagementSystem].[dbo].[OpenCloseNozzle] SET OpenReading = 0.00, CloseReading = 0.00 WHERE [Date] = GETDATE() AND TankID = 'BW-TK-DSL1' AND NozzleNo = 1
UPDATE [FuelManagementSystem].[dbo].[OpenCloseNozzle] SET OpenReading = 0.00, CloseReading = 0.00 WHERE [Date] = GETDATE() AND TankID = 'BW-TK-DSL1' AND NozzleNo = 2

SELECT QUERY:
SELECT 
    [Date], T.TankID, [OpenDip], [CloseDip], [ORNozzle1], [CRNozzle1], [ORNozzle2], [CRNozzle2]
FROM [FuelManagementSystem].[dbo].[OpenCloseTank] T
INNER JOIN 
(
    SELECT [TankID], [Date], SUM([1]) AS [ORNozzle1], SUM([2]) AS [ORNozzle2]
    FROM [FuelManagementSystem].[dbo].[OpenCloseNozzle] 
    PIVOT
    ( 
        MAX (OpenReading)
        FOR [NozzleNo] IN ([1], [2])
    ) AS P     
    WHERE CONVERT(DATE,[Date])='2019-11-09'
    GROUP BY [TankID], [Date]
) AS A  
    ON [T].[TankID] = [A].[TankID]
INNER JOIN 
(
    SELECT [TankID], SUM([1]) AS [CRNozzle1], SUM([2]) AS [CRNozzle2]
    FROM [FuelManagementSystem].[dbo].[OpenCloseNozzle] 
    PIVOT
    ( 
        MAX (CloseReading)
        FOR [NozzleNo] IN ([1], [2])
    ) AS P     
    WHERE CONVERT(DATE, [Date])='2019-11-09'
    GROUP BY [TankID]
) AS B  
    ON [T].[TankID] = [B].[TankID]
WHERE CONVERT(DATE, Whendate) = '2019-11-09'

QUERY RESULTS:

TABLE DATA:
I'm not 100% sure to understand your question but if you are looking at doing and UPDATE from a SELECT, then you may want to look at this.