인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

최윤정's profile image
최윤정

asked

Data Analysis SQL Fundamentals

Finding moving average

round 에러

Written on

·

422

1

select product_id, product_name , unit_price, round(sum(unit_price) over (order by unit_price),2) as unit_sum

from products ;

 

실행시 "SQL Error [42883]: 오류: round(real, integer) 이름의 함수가 없음"

sum(unit_price) over (order by unit_price)의 자료형이 real인 것은 확인이 되는데 왜 에러가 나는걸까요?

sqlpostgresqldbms/rdbms

Answer 1

1

권 철민님의 프로필 이미지
권 철민
Instructor

안녕하십니까,

PostgreSQL이 묵시적인 형변환에 좀 엄격합니다. 아래와 같이 명시적으로 NUMERIC으로 변환하여 적용하시면 될 것 같습니다.

round((sum(unit_price) over (order by unit_price))::numeric, 2)

감사합니다.

최윤정's profile image
최윤정

asked

Ask a question