• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

SQL Syntax for rounding up

I've got numbers like 3.32 and 3.87 that I calculate and I would like them to both round up to 4 however what I'm getting is rounding down.

Looking at some other questions that were answered I thought this might pull it off but to no avail?

CAST(ROUND(CAST(C.TRANS_QTY AS decimal(18,2)),0) AS INT) AS ROUNDED_QTY,

This does deliver a '0' decimal but it is not rounding up. i suspect I have the cast and round bits scewing with one another.

Thanks!
0
ghettocounselor
Asked:
ghettocounselor
1 Solution
 
Kelvin SparksCommented:
What version of SQL SErver. Froim 2008r2 there is the roundup function.
ROUNDUP(C.TRANS_QTY,0) should do it.


Kelvin
0
 
Tony303Commented:
SELECT CEILING(yourNumber)
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
Kelvin SparksCommented:
You may also need a cast statement with the column being passed.

Kelvin
0
 
Tony303Commented:
SELECT CEILING(CAST(C.TRANS_QTY AS decimal(18,2))) AS ROUNDED_QTY
0
 
deviprasadgCommented:
CAST(CEILING(C.TRANS_QTY) AS INT)  AS ROUNDED_QTY,
0
 
Anthony PerkinsCommented:
Froim 2008r2 there is the roundup function.
ROUNDUP(C.TRANS_QTY,0) should do it.

Not in T-SQL.  I suspect you are thinking of DAX functions.
0
 
ghettocounselorAuthor Commented:
in SQL Server 2008 R2 ceiling worked, there seems to be no 'roundup' command.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now