Hi.THere is probably a much better way to do this but....CREATE TABLE #prePivot ( [LiquidityFlag] VARCHAR(20) , [lastMkt] CHAR(4) , [lastQty] INT )CREATE TABLE #results ( [Destination] CHAR(4) , [ADDED] INT , [REMOVED] INT , [ROUTED] INT )INSERT INTO #prePivot SELECT 'ADDED', 'NSDQ', 100UNION SELECT 'REMOVED', 'ARCA', 500UNION SELECT 'REMOVED', 'NSDQ', 100UNION SELECT 'REMOVED', 'NSDQ', 100UNION SELECT 'ROUTED', 'ARCA', 500-- Populate destination dataINSERT INTO #results ( [liquidityFlag] )SELECT DISTINCT [lastMkt]FROM #prePivot-- populate ADDEDUPDATE #resultsSET [ADDED] = a.[lastQty]FROM ( SELECT [lastMkt] AS lastMkt , SUM([lastQty]) AS lastQty FROM #prePivot WHERE [liquidityFlag] = 'ADDED' GROUP BY [lastMkt] ) aWHERE a.[lastMkt] = #results.[Destination]
and repeat for the other columns in the same style as ADDED-- I'm tired and unable to think so a better solution will not be coming from me.All the best,-------------Charlie