Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/11/2007, 15:49
Avatar de Mithrandir
Mithrandir
Colaborador
 
Fecha de Ingreso: abril-2003
Mensajes: 12.106
Antigüedad: 21 años
Puntos: 25
Re: Actualizar registros en null con datos de la misma tabla

Asumiendo que SOLO tienes el número y NULL (que A SOLO tiene 5's y NULLs)... En TSQL es más o menos así:

UPDATE t1.cantidad = t2.cantidad
FROM tabla t1
INNER JOIN (
SELECT id, Max(cantidad)
FROM tabla
WHERE cantidad IS NOT NULL
GROUP BY id) t2
ON t1.id = t2.id
__________________
"El hombre, en su orgullo, creó a Dios a su imagen y semejanza."
Friedrich Nietzsche