Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- group by
- Lv. 2
- LEVEL 2
- join
- 프로그래머스
- javascript
- programmers
- SQL
- Java
- 파이썬
- 백준
- SQL 고득점 KIT
- 티스토리챌린지
- Python
- 동적계획법
- softeer
- Lv. 0
- bfs
- Dynamic Programming
- 오블완
- Lv. 3
- Baekjoon
- DP
- 자바스크립트
- level 3
- 너비 우선 탐색
- Lv. 1
- 소프티어
- 깊이 우선 탐색
- dfs
Archives
- Today
- Total
몸과 마음이 건전한 SW 개발자
[HackerRank-MSSQL] 해커랭크 Aggregation Weather Observation Station 13 본문
SQL/MSSQL
[HackerRank-MSSQL] 해커랭크 Aggregation Weather Observation Station 13
스위태니 2026. 4. 21. 11:54728x90
문제 링크
https://www.hackerrank.com/challenges/weather-observation-station-13/problem?isFullScreen=true
Weather Observation Station 13 | HackerRank
Query the sum of Northern Latitudes having values greater than 38.7880 and less than 137.2345, truncated to 4 decimal places.
www.hackerrank.com
정답 코드
SELECT CAST(SUM(LAT_N) AS DECIMAL(10, 4))
FROM STATION
WHERE LAT_N > 38.7880 AND LAT_N < 137.2345;

느낀점
- MS SQL Server에는 TRUNCATE라는 함수가 따로 없다.
- 대신 ROUND 함수의 세 번째 인자를 활용하거나 CAST를 사용해야 한다.
- 하지만 round의 경우 해당 자리에서 자를 뿐이지 00은 원본만큼 보여준다.
- round(1234.1234, 1)
- 1234.1000
- 따라서 cast나 format을 써야하는데 format이 느리기 때문에 일부러 cast를 사용했다.
- 숫자가 너무 큰 경우 format을 사용해야 할 수 있다.
728x90