>>Frank, unless there can be multiple cInvoiceNo for the same iSaleId, how about
>>
SELECT TOP 2 c_Test.*,val(cInvoiceNo) as iord;
>> FROM c_Test ;
>> ORDER BY iord desc
>
>Yeah, I was wondering as well why a subquery was used. I wonder why this was not noticed by anyone else in this thread. Then I even saw subqueries within subqueries for such a simple problem. Err.... ???
You're right, seems like we don't need derived table at all.
If it's not broken, fix it until it is.
My Blog