Menu

Wednesday, 26 March 2014

ROUND() Function in sql server 2008



It is used to find the round value of numerical column.

EmployeeID
EmployeeName
EmployeeSalary
1
Mayank Dixit
5000.89
2
Mona
4899.59
3
Purnima
4000
4
Payal
8000
                                                            employee

In the above table (employee), we want to return round value of numericalfield (EmployeeSalary).

Syntax
SELECT        Column Name1, ROUND (Column Name2, 0) AS SubName
FROM           TableName

Note : '0' define no value after decimal. in place of '0' may be 1 or 2 or any numerical value which define how much numerical value will take place after decimal.

Example

SELECT        EmployeeName, ROUND (EmployeeSalary, 0) AS RoundEmployeeSalary
FROM           Employee

Here RoundEmployeeSalary is a subname (alias) of column.

Output:-

EmployeeID
EmployeeName
EmployeeSalary
1
Mayank Dixit
5001
2
Mona
4900
3
Purnima
4000
4
Payal
8000

No comments: