FoxyB
FoxyB

Reputation: 61

Rounding a float to 2 decimal places in SQL

This is a column I calculated. The result looks like this: 8.434321

cast(tblCalc.property_size as float(10)) / cast((tblCalc.Total_WOs * 1000) as float(5)) as PER_1k_SQFT

How can I round this to 2 decimal places?

Upvotes: 2

Views: 19825

Answers (1)

antrafic
antrafic

Reputation: 31

If this is T-SQL, I would use round(). You can do that by using:

round([value], 2)

This will round your output to two decimal places.

For your specific example, I substituted your own columns with static values of my own:

select round(cast(104053.542 as float(10)) / cast((22.543 * 1000) as float(5)), 2) as PER_1k_SQFT

This gives me 4.62 when rounded (4.61578 when not rounded).

Upvotes: 3

Related Questions