Use of Rank() function in SQL (SQL Server,Oracle)


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)








Comments

Popular posts from this blog

SQL SERVER – TRIM() Function – UDF TRIM()