question

postonoh avatar image
postonoh asked

sql server division

Help me with this select column/column from table1 answer comes out 0.000000 or 2.500000000 I just need for it to 0.00 or 2.5 or 45.5
sql-server-2008
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Wimbush avatar image
David Wimbush answered
Check out the round() function.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered
+1 to David - but - why do you need it to be formatted so? What are you doing with the data? Because formatting numbers should usually be handled in the presentation layer, and not in the database directly.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

postonoh avatar image postonoh commented ·
Learning to work with crystal reports for the first time. and data is showing up as those numbers. I will check cr for formatting. thanks.
0 Likes 0 ·
Scot Hauder avatar image
Scot Hauder answered
ROUND by itself will not truncate the trailing zeros. You should format this in the client/report, but if that is not an option you can do it with a cast: SELECT CAST(ROUND(13.34533,2) AS decimal(6,2))
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.