강의

멘토링

커뮤니티

Inflearn Community Q&A

waveslike's profile image
waveslike

asked

Easy, core SQL data analysis for everyone

(Analysis) Monthly Sales Trend and Product-wise Sales Analysis Report Writing & Result Interpretation

오류가 발생했는데

Written on

·

296

1

코드가 잘못된건 아닌것 같아서요..
혹시 알 수 있을까요?
(코드와 오류 메세지 적어두었습니다. )
-------------------------------------------------
SELECT SUBSTR(A.reserv_data,1,6) BASE_MONTH, SUM(B.sales) TOT_SALES, SUM(DECODE(B.item_id,'M0005',B.sales,0)) STEAK_SALES FROM reservation A, order_info B WHERE A.reserv_no = B.reserv_no AND A.cancel = 'N' AND A.reserv_data BETWEEN '20170101' AND '20171231' GROUP BY SUBSTR(A.reserv_data,1,6) ORDER BY SUBSTR(A.reserv_data,1,6);
------------------------------------------------
ORA-00904: "A"."RESERV_DATA": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause: *Action: 9행, 17열에서 오류 발생

sql퍼포먼스 마케팅

Answer 1

1

mktcrmer8678님의 프로필 이미지
mktcrmer8678
Instructor

안녕하세요, SQL 코드에 오류가 있습니다.

reserv_data가 아니라 reserv_date 입니다.

아래 코드로 실행보시기 바랍니다.

감사합니다.

 

--  월별 매출 추이 분석

SELECT SUBSTR(A.reserv_date,1,6) BASE_MONTH, 

       SUM(B.sales) TOT_SALES, 

       SUM(DECODE(B.item_id,'M0005',B.sales,0)) STEAK_SALES

FROM reservation A, order_info B

WHERE A.reserv_no = B.reserv_no

AND   A.cancel    = 'N'

AND   A.reserv_date BETWEEN '20170101' AND '20171231'

GROUP BY SUBSTR(A.reserv_date,1,6)

ORDER BY SUBSTR(A.reserv_date,1,6);

 

 

waveslike님의 프로필 이미지
waveslike
Questioner

아... 감사합니다 ㅠ

waveslike's profile image
waveslike

asked

Ask a question