Hi richard ,May be this is what you want ----------------------Table Creation-------------------------------------------------------------------CREATE TABLE Temp(upc_id BIGINT,sku_id BIGINT,upc_type INT,upc_number BIGINT)INSERT INTO TempSELECT 60002838800016,2838800015,1,9312352527366 UNION ALLSELECT 60002838800017,2838800015 ,2, 2000000086927 UNION ALLSELECT 60002838800018 ,2838800015 ,2, 2000000087245 UNION ALLSELECT 60002838800019 ,2838800015 ,2, 2000000090863 UNION ALLSELECT 60002838800020 ,2838800015 ,2, 2000000093345 UNION ALLSELECT 60002838800021 ,2838800016 ,2, 2000000093346 UNION ALLSELECT 60002838800022 ,2838800016 ,2, 2000000093347 UNION ALLSELECT 60002838800023 ,2838800016 ,2, 2000000093348 UNION ALLSELECT 60002838800024 ,2838800017 ,1, 2000000093341 UNION ALLSELECT 60002838800025 ,2838800017 ,1, 2000000093342 UNION ALLSELECT 60002838800026 ,2838800017 ,1, 2000000093343----------------------Query ----------------------------------------------------------------------------SELECT upc_id ,sku_id ,upc_type ,CASE WHEN MAX(upc_type) OVER (PARTITION BY sku_id) = upc_type THEN upc_number END ASupc_number FROM Temp WHERE upc_id IN (SELECT MAX(upc_id) OVER (PARTITION BY sku_id) FROM temp)--------------------------------------------------------------------------------------------------------
---------------Murali KrishnaYou live only once ..If you do it right once is enough.......