Monday 5 December 2011

SQL Round()

The ROUND() function is used to round a numeric field to the number of decimals specified.

Syntax 


SELECT ROUND(column_name,decimals) FROM table_name


The "custmast"Table



custcode
custname
city
qty
rate
1
Siva
Srivilliputtur
50
70
2
Bala
Sivakasi
30
56
3
Kanna
Madurai
100
200.64
4
Vijay
Chennai
30
30
5
Kodee
Sandnes
60
80.68
5
Kodee
Srivilliputtur
60
30



Example :1


Select Round(Rate,0)  as Rate from custmast


Output 



Rate
70.00
56.00
201.00
30.00
81.00
30.00






Example :2


Select Round(Rate,1)  as Rate from custmast


Output 



Rate
70.00
56.00
200.60
30.00
80.70
30.00







0 comments:

Post a Comment

Followers

Powered by Blogger.