几天前我问过类似的问题,这是我的问题。我的教授提出了以下问题:找出每个影院播放的所有电影的平均收视率。显示剧院名称和计算的收视率。按等级升序排列结果。
以下是我的表格的结构:
CREATE TABLE Theatres (
Name varchar2(50) not null,
City varchar2(50) not null,
State varchar2(50) not null,
Zip number not null,
Phone varchar2(50) not null,
PRIMARY KEY (Name)
);
CREATE TABLE Movies (
Title varchar2(100) not null,
Rating NUMBER not null,
Length NUMBER not null,
ReleaseDate date not null,
PRIMARY KEY (Title),
CHECK (Rating BETWEEN 0 AND 10),
CHECK (Length > 0),
CHECK (ReleaseDate > to_date('1/January/1900', 'DD/MONTH/YYYY'))
);
CREATE TABLE ShownAt (
TheatreName varchar2(50) not null,
MovieTitle varchar2(100) not null,
PRIMARY KEY (TheatreName, MovieTitle),
FOREIGN KEY (TheatreName) REFERENCES Theatres(Name),
FOREIGN KEY (MovieTitle) REFERENCES Movies(Title)
);
SELECT
AVG(Movies.Rating),
Theatres.Name
FROM Theatres
JOIN ShownAt ON ShownAt.TheatreName = Theatres.Name
JOIN Movies ON ShownAt.MovieTitle = Movies.Title
ORDER BY Movies.Rating ASC
看到什么不寻常的地方?我不断收到一条错误消息,指出 SQL 错误:ORA-00937: not a single-group group function 00937. 00000 - “not a single-group group function”。原谅我的初学者。