on 07-18-2011 4:10 AM
Estimados:
Tengo la siguiente query, la cual me trae los ultimos costos ingresados de una importacion X. El problema es que necesito agregarle que sea por rango de fecha y no lo he conseguido, alguien puede ayudarme con esto?
Gacias.
SELECT DISTINCT T0.[BillOfLad] as 'BL', (SELECT MAX(Y.DocNum) FROM OIPF Y WHERE Y.BillOfLad = T0.[BillOfLad] ) as 'Nº Ingreso', T0.[SuppName] as 'Proveedor', T2.AlcCode, T2.[AlcName] as 'Costo Imp', T1.[CostSum],
(SELECT MAX((X.[BeforeVat]-X.CostSum)) from OIPF X Where X.BillOfLad= T0.BillOfLad) as 'Valor FOB' FROM OIPF T0
INNER JOIN IPF2 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OALC T2 ON T1.AlcCode = T2.AlcCode
GROUP BY T0.[BillOfLad], T0.[SuppName], T2.AlcCode, T2.[AlcName], T1.[CostSum],T0.[BeforeVat], T0.[CostSum]
VMC.
Hola Viviana
Prueba esta
SELECT DISTINCT T0.BillOfLad as 'BL', (SELECT MAX(Y.DocNum) FROM OIPF Y WHERE Y.BillOfLad = T0.BillOfLad AND (Y.DocDate between [%0] and [%1])) as 'Nº Ingreso', T0.SuppName as 'Proveedor', T2.AlcCode, T2.AlcName as 'Costo Imp', T1.CostSum,
(SELECT MAX((X.BeforeVat-X.CostSum)) from OIPF X Where X.BillOfLad= T0.BillOfLad and (X.DocDate between [%0] and [%1])) as 'Valor FOB' FROM OIPF T0
INNER JOIN IPF2 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OALC T2 ON T1.AlcCode = T2.AlcCode
where (T0.DocDate between [%0] and [%1])
GROUP BY T0.BillOfLad, T0.SuppName, T2.AlcCode, T2.AlcName, T1.CostSum,T0.BeforeVat, T0.CostSum
Añade los corchetes a las variables % porque no se copìan bien aquí
Un saludo,
Tere
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola Viviana,
Prueba esta
SELECT DISTINCT T0.BillOfLad as 'BL', (SELECT MAX(Y.DocNum) FROM OIPF Y WHERE Y.BillOfLad = T0.BillOfLad AND (Y.DocDate between and )) as 'Nº Ingreso', T0.SuppName as 'Proveedor', T2.AlcCode, T2.AlcName as 'Costo Imp', T1.CostSum,
(SELECT MAX((X.BeforeVat-X.CostSum)) from OIPF X Where X.BillOfLad= T0.BillOfLad and (X.DocDate between and )) as 'Valor FOB' FROM OIPF T0
INNER JOIN IPF2 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OALC T2 ON T1.AlcCode = T2.AlcCode
where (T0.DocDate between and )
GROUP BY T0.BillOfLad, T0.SuppName, T2.AlcCode, T2.AlcName, T1.CostSum,T0.BeforeVat, T0.CostSum
Un saludo,
Tere
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.