중급 SQL Server
Ginger Grant
Instructor
ABS()를 사용하여 음수가 아닌 값을 반환합니다
ABS(number)
SELECT ABS(-2.77), ABS(3), ABS(-2)
+--------------------+-------------------+-------------------+
|(No column name) |(No column name) |(No column name) |
+--------------------+-------------------+-------------------+
|2.77 |3 |2 |
+--------------------+-------------------+-------------------+
SELECT DurationSeconds, ABS(DurationSeconds) AS AbsSeconds
FROM Incidents
+--------------------+--------------------+
|DurationSeconds |AbsSeconds |
+--------------------+--------------------+
|-25.36 |25.36 |
|-258482.44 |258482.44 |
|45.66 |45.66 |
+--------------------+--------------------+
SELECT SQRT(9) AS Sqrt,
SQUARE(9) AS Square
+--------+-----------+
|Sqrt |Square |
+--------------------+
|3 |81 |
+--------+-----------+
LOG()는 자연 로그를 반환합니다
LOG(number [,Base])
SELECT DurationSeconds, LOG(DurationSeconds, 10) AS LogSeconds
FROM Incidents
+--------------------+--------------------+
|DurationSeconds |LogSeconds |
+--------------------+--------------------+
|37800 |4.577491799837225 |
|5 |0.6989700043360187 |
|20 |1.301029995663981 |
...
+--------------------+--------------------+
0의 로그는 오류를 발생시키므로 사용할 수 없습니다
SELECT LOG(0, 10)
An invalid floating point operation occurred.
중급 SQL Server