• It looks like something along those lines might help (untested due to missing sample data in a ready to use format...):

    WITH cte AS

    (

    SELECT DISTINCT articulo

    FROM unknown

    )

    SELECT

    uk.articulo,

    uk.bodega,

    uk.cant_disponible,

    uk.cantidad,

    uk.fecha_hora_transac

    FROM cte

    CROSS APPLY

    (

    SELECT TOP 1

    u.articulo,

    u.bodega,

    u.cant_disponible,

    u.cantidad,

    u.fecha_hora_transac

    FROM unknown u

    INNER JOIN cte ON cte.articulo = u.articulo

    ORDER BY u.fecha_hora_transac DESC

    )uk

    If there's already a normalized table to get the articulo values, use this table instead of the cte.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]