Back
A column height is in int type in my SQL Server table. I need to do a division and produce the result as a decimal in my query.
Select (height/10) as HeightDecimal
How would I cast and so that the HeightDecimal is no longer integer?
Try the following code:
SELECT height/10.0 AS HeightDecimal FROM dbo.whatever;
If you require a specific precision scale, then say so:
SELECT CONVERT(DECIMAL(16,4), height/10.0) AS HeightDecimal FROM dbo.whatever;
Want to learn more concepts related to SQL? Join this SQL Course by Intellipaat.
31k questions
32.8k answers
501 comments
693 users