"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, April 16, 2011

Rank() function in SQL Server

 Hi *.*,
Understanding Server function makes our code less and more flexible.i believe it strongly.Here is a Another fuction provided by SQL server RANK().

SELECT Rank() OVER (ORDER BY receiptdate ) as Firt_Arrival,locationnumber,receiptdate FROM inventorylocsubdetail

Here Rank() fn would return the rank based on the ReceiptDate. But this would be jumbling if there are same rank more than one.

E.g: here rank 4 repeating for three records,because of this the next rank is 7 (4,4,4,7)


 Hope u got it... If any trouble Ask me.
Stay tune..
Have a nice day... 'N happy Coding :)

No comments: