• Sharon,

    You are asking two separate questions here:

    " is there a way to compare the next record in the query to the previous record"

    and

    "i would like to see if there is a different unit cost on a sku as long as it is the same season, style and color "

    Andrew and Celko have responded to your first question by trying to make it a teachable moment about set-based thinking. SQL does not guarantee any order of records unless you tell it an order. Your order by clause is less than the fields driving your groups, so within a group, "next record" cannot be predicted. In the provided query, "next record" is an ambiguous concept unless you can articulate what it means to be the next record.

    Now, your initial idea of using "next record" as what you think you need to solve the business question can eventually get the answer with further elaboration that would allow the data in one record to determine what the "next record" would be, but really it doesn't need it. An answer with this approach is subject to misinterpretation and a more complicated than necessary query.

    "i would like to see if there is a different unit cost on a sku as long as it is the same season, style and color "

    Does this answer the business question:

    SELECT

    SCDIVN AS COMPANY,

    SCSEAS AS SEASON,

    SCSTYL AS STYLE,

    SCCOLR AS COLOR,

    SCSKU# AS SKU,

    Min(sccost) as lowestcost,

    Max(sccost) as highestcost

    FROM dbo.SHIPSKU#

    WHERE (SCDIVN = 'aaa')

    GROUP BY SCDIVN, SCSEAS, SCSTYL, SCCOLR, SCSKU#

    Having Min(sccost) <> Max(sccost)