나는 이렇게 학습한다/Algorithm & SQL
SQL Basics: Truncating
daco2020
2022. 6. 30. 20:50
Given the following table 'decimals':
decimals table schema
- id
- number1
- number2
Return a table with a single column towardzero where the values are the result of number1 + number2 truncated towards zero.
Solution:
SELECT
TRUNC(number1 + number2) AS towardzero
FROM
decimals
Result:
towardzero |
1 |
2 |
0 |
2 |
2 |
1 |
Reference:
ROUND / TRUNC / MOD 반올림과 버림 그리고 나머지값 구하기
round .round(data) : 반올림하여 정수로 변환 .round(data,1) : 소수부 둘째자리에서 반올림한다. .round(data, -1 ) : 정수부의 첫째자리에서 반올림한다. Select round(Sysdate - Hiredate,1) from employee; T..
dearfriend.tistory.com