Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Selecting data from a change log where the date falls between two rows. RE: Selecting data from a change log where the date falls between two rows.

  • SELECT

    Price

    FROM

    PHistory

    WHERE

    Product_Reference = 100014

    AND

    Change_Date = (

    SELECT

    MAX(Change_Date)

    FROM

    PHistory

    WHERE

    Product_Reference = 100014

    AND

    Change_Date < 20070906

    )

    Of course, you may get into trouble if the price changes more than once on the same date.

    John