Skip to Content
avatar image
Former Member

Query para costos maximo y costos minimo por rango de fechas

Buenos Dias gente,

realice el siguiente query para saber los costos maximos y costos minimo de mis productos por rango de fecha, pero no me da datos reales

si me podria ayudar se los agradeceria

SELECT DISTINCT T0.[ItemCode], T0.[Dscription],

(select Max (PDN1.StockSum/PDN1.Quantity) from  PDN1 WHERE PDN1.Itemcode=T0.ItemCode) AS 'Maximo',

(select Min (PDN1.StockSum/PDN1.Quantity)  from  PDN1 WHERE PDN1.Itemcode=T0.ItemCode) AS 'Minimo'

FROM PDN1 T0  INNER JOIN OPDN T1 ON T0.DocEntry = T1.DocEntry

WHERE T1.[DocDate] BETWEEN '[%0]' AND '[%1]'and t1.DocType='I'

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 29, 2015 at 08:29 PM

    Hola Cristiano.

    prueba la siguiente Query, o adaptala según tu necesidad

    SELECT

    T0.ItemCode,

    T0.Dscription,

    MAX(T0.StockSum/NULLIF(T0.Quantity,0)) 'MAX',

    MIN(T0.StockSum/NULLIF(T0.Quantity,0)) 'MIN'

    FROM  PDN1 T0  INNER JOIN OPDN T1 ON T0.DocEntry = T1.DocEntry

    GROUP BY

    T0.ItemCode,

    T0.Dscription

    Saludos

    Add comment
    10|10000 characters needed characters exceeded