나는 이렇게 학습한다/Algorithm & SQL
Easy SQL: Rounding Decimals
daco2020
2022. 5. 30. 20:15
반응형
Given the following table 'decimals':
** decimals table schema **
- id
- number1
- number2
Return a table with two columns (number1, number2), the value in number1 should be rounded down and the value in number2 should be rounded up.
Solution:
SELECT
FLOOR(number1) as number1,
CEIL(number2) as number2
FROM
decimals
Result:
number1 | number2 |
2409 | -261 |
1411 | -4694 |
2666 | -2280 |
3616 | -2987 |
4110 | -2420 |
3654 | -1463 |
Reference:
postgresql 의 반올림 함수들
postgreSQL 에서 반올림 함수들 사용 예시 반올림 관련 함수들 round : 일반적인 반올림 함수 ceil : 소수점 자리의 숫자를 무조건 올린다. (방의) 천정으로 만든다는 의미. floor: 소수점 자리의 숫자를
kugancity.tistory.com
반응형