-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
오류가 발생했는데
22.06.27 17:31 작성 조회수 152
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열에서 오류 발생
혹시 알 수 있을까요?
(코드와 오류 메세지 적어두었습니다. )
-------------------------------------------------
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열에서 오류 발생
답변을 작성해보세요.
1
데이터셰프
지식공유자2022.06.28
안녕하세요, 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);
답변 1