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
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
SQL: Regex String to Table (0) | 2022.07.03 |
---|---|
SQL with Harry Potter: Sorting Hat Comparators (0) | 2022.07.01 |
Easy SQL: Counting and Grouping (0) | 2022.06.29 |
Countries Capitals for Trivia Night (SQL for Beginners #6) (0) | 2022.06.28 |
First and last IP in a network (0) | 2022.06.27 |