Need help

  • I have a table that has product receiving in it, I need to retrieve the max receipt date for an item and the user who received it - how can I do this in sql??

    Pete Gentile

  • Well, with no details from which to work, here is a shot in the dark.

    WITH basedata AS (

    SELECT

    ROW_NUMBER() OVER (PARTITION BY ProductID ORDER BY ReceiptDate DESC) AS rn,

    ProductID,

    ReceiptDate,

    UserName

    FROM

    dbo.ProductTable -- Or what ever it is called

    )

    SELECT

    ProductID,

    ReceiptDate,

    UserName

    FROM

    basedata

    WHERE

    rn = 1;

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply