[MySQL] 숫자함수

ABS

  • 절대값 반환
SELECT ABS(-10) => 10

CEIL

  • 올림
SELECT CEIL(1.3) => 2
SELECT CEIL(-1.3) => -1

FLOOR

  • 내림
SELECT FLOOR(1.7) => 1
SELECT FLOOR(-1.7) => -2

MOD

  • 나눠서 나머지 값 반환
SELECT MOD(23, 10) => 3
SELECT MOD(23, 0) => NULL

POW

  • 제곱한 결과 값 반환
SELECT POW(2, 3) => 8
SELECT POW(2, -3) => 0.125

ROUND

  • 반올림
SELECT ROUND(217.654321) => 218
SELECT ROUND(217.654321, 1) => 217.7
SELECT ROUND(217.654321, 2) => 217.65
SELECT ROUND(217.654321, 3) => 217.654

SELECT ROUND(217.654321, -1) => 220
SELECT ROUND(217.654321, -2) => 200

TRUNCATE

  • 버림
SELECT TRUNCATE(217.654321, 0) => 217
SELECT TRUNCATE(217.654321, 1) => 217.6
SELECT TRUNCATE(217.654321, 2) => 217.65
SELECT TRUNCATE(217.654321, 3) => 217.654

SELECT TRUNCATE(217.654321, -1) => 210
SELECT TRUNCATE(217.654321, -2) => 200

SQRT

파라미터 x(양수) 에 대한 제곱근을 반환

SELECT SQRT(4) => 2
SELECT SQRT(40) => 6.324555320336759
SELECT SQRT(-16) => NULL

links

social