WITH tblwDuplicados(numeroCuentaCliente,num) AS (
SELECT
numeroCuentaCliente,
ROW_NUMBER() OVER(partition by numeroCuentaCliente ORDER BY fchCreado DESC)
FROM tblCuentaDireccion
)
DELETE FROM tblwDuplicados
WHERE num > 1;
WITH tmpResumenGestiones(creadoPor,num) as (
SELECT
creadoPor,
ROW_NUMBER() OVER (PARTITION BY creadoPor ORDER BY fecha) as num
FROM tblResumenGestiones
WHERE fecha = '28/05/2015'
)
DELETE FROM tmpResumenGestiones WHERE num = 1