• In the future, you should provide DDL and consumable sample data in the format I've included below.

    -- DDL

    DECLARE @T TABLE

    (RecordID INT, ItemID INT, MaxOfCost MONEY)

    -- Consumable sample data

    INSERT INTO @T

    SELECT 43392,3880,$50.00

    UNION ALL SELECT 39056,3881,$93.75

    UNION ALL SELECT 33941,3881,$97.50

    UNION ALL SELECT 33970,3881,$97.50

    UNION ALL SELECT 38950,3881,$98.75

    UNION ALL SELECT 40417,3881,$96.56

    UNION ALL SELECT 36491,3882,$30.00

    UNION ALL SELECT 37265,3883,$6.50

    UNION ALL SELECT 35054,3883,$4.50

    UNION ALL SELECT 33658,3884,$14.94

    UNION ALL SELECT 36585,3884,$18.77

    UNION ALL SELECT 33134,3884,$14.75

    ;WITH MyData AS (

    SELECT RecordID, ItemID, MaxOfCost

    ,n=ROW_NUMBER() OVER (PARTITION BY ItemID ORDER BY MaxOfCost DESC)

    FROM @T)

    SELECT RecordID, ItemID, MaxOfCost

    FROM MyData

    WHERE n = 1

    Hopefully this provides the results you seek but let us know.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St