원문:Eastwood has had played several iconic characters throughout his acting career. Write a subquery that returns the character name, total number of appearances in film, total minutes on film, year of first appearance, and year of last appearance for each character that he has played more than once. In addition, return the average IMDB score, average number of votes, and average profit for the movies that character appears in. Make sure to rename calculated fields that appear in the results.
해석: Eastwood라는 배우는 그의 연기 경력동안 여러 타입의 상징적 인물들을 연기해 왔다.
먼저, 그의 연기경력 동안 그가 한 번이상 연기한 각 캐릭터에 대한 character name(캐릭터 이름), total number of appearances in flim (영화 출연 총 횟 수), total minutes on film (영화 상영 총 분), year of first appearance (첫 출연연도), year of last appearance (마지막 출연연도)를 보여주는 subquery를 만들어라.
그리고, 캐릭터가 출연했던 영화에 대한 the average IMDB Score (평균 평점), average number of votes (평균 투표수), average profit (평균 수익)를 보여주는 쿼리를 만들어라.
여기서, 평균 평점, 평균 투표수, 평균 수익은 테이블 column에 나와있어서 구할 수가 있는데, subquery에서 요구하는 영화출연 총횟수, 영화 상영 총분, 첫 출연연도, 마지막 출연연도는 거기에 맞는 table column이 없어서 어떻게 구해야할 지 모르겠네요. 테이블 항목 전부 첨부하겠습니다..
Character Name은 principal 테이블에서 role이 actor인 것에만 나옵니다.
테이블 column에서 subquery가 요구하는 항목들을 만들 수 있나요?
SELECT b.CharacterName , COUNT(*) AS "total number of appearances in flim" , SUM(c.RunTime) AS "total minutes on film" , MIN(c.ReleaseYear) AS "year of first appearance" , MAX(c.ReleaseYear) AS "year of last appearance" , AVG(c.Score) AS "the average IMDB Score" , AVG(c.Votes) AS "average number of votes" , AVG(c.BoxOffice - c.Budget) AS "average profit" FROM Person a INNER JOIN Principal b ON a.PersonID = b.PersonID INNER JOIN Movie c ON b.MovieID = c.MovieID WHERE a.PersonFirst = 'Clint' AND a.PersonLast = 'Eastwood' AND b.Role = 'actor' GROUP BY b.CharacterName HAVING COUNT(*) > 1 ;
감사합니다. 알려주신대로 run해보니
ORA-00972: identifier is too long 이런 오류가 뜨네요.
그 SELECT이랑 FROM사이에 입력된 내용이 많아서 그러는 건가요?
, COUNT(*) AS "total number of appearances in flim" , SUM(c.RunTime) AS "total minutes on film" , MIN(c.ReleaseYear) AS "year of first appearance" , MAX(c.ReleaseYear) AS "year of last appearance"
그러면 이 부분을 subquery로 만든 다음 이걸 넣는 방법도 가능한가요?
즉, 위에 4항목을 한 다음 전체에 넣는 방식이요.