TSQL invalid where clause in sub query
I have a situation where I need select the current and previous order amount using a select statement.

Order Table:

    OrderId
    OrderDate
    OrderAmount

Current Select Statement:

    SELECT o.OrderId, o.OrderDate, o.OrderAmount, po.OrderAmount
    FROM Order o
    LEFT JOIN (
       SELECT TOP(1) so.OrderAmount
       FROM Order so
       WHERE so.OrderId <> o.OrderId
       ORDER BY so.OrderDate DESC
       ) po

The problem is that the "where" clause in the sub query is not allowed. Is there another method for getting this information

TSQL invalid where clause in sub query
===

I have a situation where I need select the current and previous order amount using a select statement.

Order Table:

    OrderId
    OrderDate
    OrderAmount

Current Select Statement:

    SELECT o.OrderId, o.OrderDate, o.OrderAmount, po.OrderAmount
    FROM Order o
    LEFT JOIN (
       SELECT TOP(1) so.OrderAmount
       FROM Order so
       WHERE so.OrderId <> o.OrderId
       ORDER BY so.OrderDate DESC
       ) po

The problem is that the "where" clause in the sub query is not allowed. Is there another method for getting this information
