create table #aaa
(A_1 float, A_2 float, A_3 float, A_4 float, A_5 float,
A_6 float, A_7 float, A_8 float, A_9 float, A_10 float)
insert into #aaa
values(1.05, 1.15, 1.25, 1.35, 1.45, 1.55, 1.65, 1.75,1.85, 1.95)
select a_1, round(a_1, 1), a_2, round(a_2, 1), a_3, round(a_3, 1), a_4, round(a_4, 1), a_5, round(a_5, 1),
a_6, round(a_6, 1), a_7, round(a_7, 1), a_8, round(a_8, 1), a_9, round(a_9, 1), a_10, round(a_10, 1)
from #aaa
a_2, a_7 컬럼의 round 값이 1.2, 1.7 로 나오는게 정상아닌가요?
왜 a_2, a_7의 값은 1.1, 1.6으로 나오나요?
또는
create table #bbb
(A_1 float, A_2 float)
insert into #bbb
values(94.05, 94.45)
select a_1, round(a_1, 1), a_2, round(a_2, 1)
from #bbb
a_1 은 94, a_2는 94.5 .. round가 안될꺼면 다 안되든지
될꺼면 다 되든지..
왜 이런지 이해가 가질 않습니다.
mssql의 버그 인가요??
아시는 분 답변좀 부탁 드립니다.
Comment 3
-
jevida(강성욱)
2012.12.07 23:40
ROUND 함수 관련 MSND 입니다.
-
호짱
2012.12.10 16:49
답변 감사드립니다.
decimal로 처리 했습니다.
좀 자신없지만 댓글 달아봅니다.
BOL에서 float를 검색해보면
float 및 real 데이터 형식은 근사 데이터 형식입니다. float 및 real의 동작은 근사 숫자 데이터 형식에 대한 IEEE 754 사양을 따릅니다.
라고 나옵니다.
근사치라네요.
float 대신에 numeric(10,2) 이런식으로 쓰면 원하시는 결과가 나옵니다.