using sql server 2005I am returning the rownum of a table based on the latest orderDate which is good, however I want a query where I only return the record if rownum=1.My original query that returns all records regardless of rownum value is below:select row_number() over (partition by custID order by orderDate DESC) rownum,orderID, custID, orderDate from ORDERS
however I want to return only those records where rownum=1 but when I try this query it gives me an error, the query:select row_number() over (partition by custNum order by orhDate DESC) rownum,orderNum, custNum, orhDate from ORDERHEAD WHERE rowNum=1
when I try this I get the error:<error>invalid column name "rownum"</error>anyways, do any of you know how I can fix the syntax of my query to only return the records where rownum=1?thanksMC