Reputation: 407
I have a number with two digits after the decimal point; I try to cast this number using CAST
for example:
Select SUM(CAST((123345.56) as decimal(28, 2))) * 100 AS AMOUNT
I get the following result
12334556.00
but I want get only 12334556
without displaying two digits after the decimal point.
Thank you.
Upvotes: 1
Views: 2360
Reputation: 151
Integer data type is whole numbers, so cast your calculated value as int.
Select SUM(CAST((123345.56 * 100) as int)) AS AMOUNT
Upvotes: 0
Reputation: 25013
It is not clear what you really want to do, but
SELECT SUM(CAST((123345.56 * 100.0) AS DECIMAL(28,0))) AS AMOUNT
gives 12334556
.
When you use a number in the format 1234.56 it is a decimal literal in SQL Server: see "decimal constants" in Constants (Transact-SQL).
Upvotes: 2