Both TRUC and ROUND are single value functions.
TRUNC:
TRUNC function truncates that is in other words cuts off to the digits specified.
The general syntax of TRUNC function is:
TRUNC(number, precision);
For instance:
Suppose the value of salary in employee table for ename= ’Exforsys’ is 55.666
Then
Select TRUNC(salary,2) from employee where ename=’Exforsys’;
Gives output as
TRUNC(salary)
------------------
66.66
ROUND:
ROUND function rounds the number to a specified number of decimal places. The general syntax of TRUNC function is:
ROUND(number, precision);
For instance:
Suppose the value of salary in employee table for ename= ’Exforsys’ is 55.666
Then
Select ROUND(salary,2) from employee where ename=’Exforsys’;
Gives output as
ROUND(salary)
------------------
66.67
What is the difference between ROUND and TRUNC function in SQL?
Both TRUC and ROUND are single value functions.
TRUNC:
TRUNC function truncates that is in other words cuts off to the digits specified.
The general syntax of TRUNC function is:
For instance:
Suppose the value of salary in employee table for ename= ’Exforsys’ is 55.666
Then
Gives output as
ROUND:
ROUND function rounds the number to a specified number of decimal places. The general syntax of TRUNC function is:
For instance:
Suppose the value of salary in employee table for ename= ’Exforsys’ is 55.666
Then
Gives output as
Profile Answers by GeekAdmin Questions by GeekAdmin
Questions by GeekAdmin answers by GeekAdmin
Related Answered Questions
Related Open Questions