--
WITH FUENTE AS (
SELECT ROW_NUMBER() OVER(PARTITION BY Col1,Col2,Col3 ORDER BY (SELECT NULL)) AS R_ID,Col1,Col2,Col3
FROM MyTable) DELETE FROM FUENTE WHERE R_ID > 1;
--
ejemplo práctico:
WITH FUENTE AS (
SELECT ROW_NUMBER() OVER(PARTITION BY tipo, num_factura ORDER BY (SELECT NULL)) AS R_ID,tipo, num_factura
FROM leaseoper..t_facturas_joel_borrar) DELETE FROM FUENTE WHERE R_ID > 1;
No hay comentarios:
Publicar un comentario