I have a salary table with this column
EMPLOYEE_NAME SALARY
------------------------
ANNA 113750
MARRY 124300
BELLA 105100
<
You can use the CEILING
function.
Like:
SELECT EMPLOYEE_NAME CEILING(SALARY)
Read this for further details
Short summary from the above link:
In SQL Server (Transact-SQL), the CEILING function returns the smallest integer value that is greater than or equal to a number.
Divide the salary by the fraction. Use ceiling to round up. Then multiply by the fraction.
Declare @salary table (Employee_name nvarchar(50), Salary money)
Declare @fraction money = 5000
insert into @salary
values
('ANNA', 113750),
('MARRY', 124300),
('BELLA', 105100)
update @salary
set Salary = ceiling(salary/@fraction)*@fraction
select * from @salary
Try below CEILING method :
DECLARE @fraction MONEY = 1000
SELECT CEILING(113750/@fraction)*@fraction
SELECT CEILING(124300/@fraction)*@fraction
SELECT CEILING(105100/@fraction)*@fraction
Unlike ROUND
(which rounds up and down) the CELING
function (which you want to round up) has no length parameter (as in ROUND(salary, -3)
). So divide and multiply to get the desired result:
select employee_name, ceiling(salary / 1000.0) * 1000.0 as salary
from mytable;
CEILING
is documented here: https://msdn.microsoft.com/de-de/library/ms189818.aspxROUND
is documented here: https://msdn.microsoft.com/de-de/library/ms175003.aspxtry this.
select EMPLOYEE_NAME, ceiling(salary / 1000.0) * 1000.0 as SALARY from table;