
05/05/2011, 16:10
|
 | Colaborador | | Fecha de Ingreso: agosto-2006 Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 6 meses Puntos: 774 | |
Respuesta: Subtotalizar registros en consulta Para el punto 1 select t1.nit, t1.nombre provedor, t1.tipo_pedido, sum(total_abono)
from
(
SELECT DISTINCT T.NIT
,C.NOMBRE PROVEDOR
,M.TIPODCTO TIPO_PEDIDO
,cast (A.VALOR AS decimal)TOTAL_ABONO
FROM MVTRADE M INNER JOIN TRADE T ON M.ORIGEN = T.ORIGEN AND M.TIPODCTO=T.TIPODCTO AND M.NRODCTO=T.NRODCTO
INNER JOIN MTPROCLI C ON T.NIT=C.NIT
INNER JOIN ABOCXP A ON T.NIT = A.NIT
WHERE m.TIPODCTO ='FP' OR M.TIPODCTO = 'PC'
) as t1 group by t1.nit, t1.nombre provedor, t1.tipo_pedido
Saludos!!
__________________ What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me |