Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/01/2011, 09:10
Avatar de flaviovich
flaviovich
 
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 2.951
Antigüedad: 18 años, 8 meses
Puntos: 39
Respuesta: Sumar valores de una misma columna y sin repetir otros

Prueba de esta forma:
Código SQL:
Ver original
  1. SELECT T1.*, T1.Porcentaje+ISNULL(T3.Porcentaje,0) AS Porcentaje_Acumulado
  2. FROM tutabla T1
  3. INNER JOIN (
  4.     SELECT T1.[Cod.Art],(SELECT MAX([Cod.Art]) FROM tutabla WHERE [Cod.Art] < T1.[Cod.Art]) [IdAnt]
  5.     FROM tutabla T1
  6. ) T2 ON T1.[Cod.Art] = T2.[Cod.Art]
  7. LEFT JOIN tutabla T3 ON T2.IdAnt = T3.[Cod.Art]
__________________
No repitamos temas, usemos el Motor de busquedas
Plantea bien tu problema: Ayúdanos a ayudarte.