I have a query where i have used row_number() function. My query is like the following
SELECT ID,
ROW_NUMBER() over(order by Position desc) Rank
FROM Tbl
Problem is Rank is producing a bigint value. But i want to convert it to an int. How can i do it?
This isn't particularly difficult;
SELECT ID,
CAST(ROW_NUMBER() over(order by Position desc) AS INT) Rank
FROM Tbl
SELECT name,
cast (ROW_NUMBER() over(order by object_id desc) as int) Rank
FROM sys.objects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With