11/03/2013, 18:24
|
| | Fecha de Ingreso: marzo-2013 Ubicación: Caracas
Mensajes: 9
Antigüedad: 11 años, 9 meses Puntos: 0 | |
Respuesta: Problema con Select y tablas T explico me diste esto
SELECT T0.DocNum,T0.[CardCode], T0.[DocTotal] AS 'TOTAL EN BS' ,SUM(T1.[Quantity]) AS 'TOTAL' INTO #temp FROM ORPD T0 INNER JOIN RPD1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDate] >='20130101' AND T0.[DocDate] <= '20130125'
GROUP BY T0.DocNum,T0.[CardCode],T0.[DocTotal]
ORDER BY T0.[CardCode]
SELECT num,num_doc,t1.codigo_doc,total_bs,total FROM(
SELECT ROW_NUMBER() over(partition BY codigo_doc ORDER BY codigo_doc) AS rn, num,num_doc,codigo_doc FROM #temp) as t1
LEFT JOIN (SELECT codigo_doc,SUM(total_bs) total_bs,SUM(total) total FROM #temp group by codigo_doc) as t2 on (t1.codigo_doc=t2.codigo_doc and t1.rn=1)
WHERE rn=1
El Sql server me dic que esto (SELECT num,num_doc,t1.codigo_doc,total_bs,total) no son nombres validos de columnas x eso digo que usas campos que no existen |