Here is the code which works: SELECT fenumber, finvqty, forderqty, fshipbook, fshipbuy, fshipmake, fsono, (forderqty -(fshipbook + fshipbuy + fshipmake)) AS LeftToShip, (forderqty - finvqty) AS LeftToInvoice, funetprice FROM dbo.sorels WHERE (forderqty > (fshipbook + fshipbuy + fshipmake) AND forderqty > finvqty) AND (forderqty -(fshipbook + fshipbuy + fshipmake)) <> (forderqty - finvqty)
Why can't I reference the Aliases in the Where clause such as this? SELECT fenumber, finvqty, forderqty, fshipbook, fshipbuy, fshipmake, fsono, (forderqty -(fshipbook + fshipbuy + fshipmake)) AS LeftToShip, (forderqty - finvqty) AS LeftToInvoice, funetprice FROM dbo.sorels WHERE (forderqty > (fshipbook + fshipbuy + fshipmake) AND forderqty > finvqty) AND LeftToShip <> LeftToInvoice