我有一个数据库ticket_price将PK作为Ticket_type 和电影的PK为movie_ID
这是我的代码
SET SERVEROUTPUT ON
DECLARE
V_MOVIE_TITLE
MOVIE_TITLE.MOVIE%TYPE;
V_AVG_PRICE
PRICE.TICKET_PRICE%TYPE;
BEGIN
SELECT MOVIE_TITLE INTO V_MOVIE_TITLE
FROM MOVIE,
(SELECT AVG(PRICE) INTO V_AVG_PRICE FROM TICKET_PRICE)
TICKET_PRICE
WHERE MOVIE_TITLE = 'STATE OF THE UNION';
DBMS_OUTPUT.PUT_LINE ('MOVIE NAME AVERAGE PRICE');
DBMS_OUTPUT.PUT_LINE ('======================================');
DBMS_OUTPUT.PUT_LINE (' ' || V_MOVIE_TITLE.MOVIE_ID || ' ' || V_AVG_PRICE.TICKET_PRICE);
END;
/
错误似乎与子查询平均(价格) 如何让它正常运行?
答案 0 :(得分:0)
SET SERVEROUTPUT ON
DECLARE
V_MOVIE_TITLE
MOVIE_TITLE.MOVIE%TYPE;
V_AVG_PRICE
PRICE.TICKET_PRICE%TYPE;
BEGIN
SELECT MOVIE_TITLE INTO V_MOVIE_TITLE
FROM MOVIE WHERE MOVIE_TITLE = 'STATE OF THE UNION';
SELECT AVG(PRICE) INTO V_AVG_PRICE FROM TICKET_PRICE TICKET_PRICE;
DBMS_OUTPUT.PUT_LINE ('MOVIE NAME AVERAGE PRICE');
DBMS_OUTPUT.PUT_LINE ('======================================');
DBMS_OUTPUT.PUT_LINE (' ' || V_MOVIE_TITLE.MOVIE_ID || ' ' || V_AVG_PRICE.TICKET_PRICE);
END;
/