So I've been doing this all night - can't quite understand my homework, and sadly my professor is unavailable on the weekend. Here it goes: Find the titles of the newest movies shown in each city. Display the city name and the newest movie title ordered by city name and movie title.
Here are my table declares (and thank you to EVERYONE helping me out tonight, I owe you big time).
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)
);
Here is what I have so far (based on help from other StackOverflow members from earlier questions):
SELECT m.title AS m_title,
t.city,
m.title
FROM THEATRES t
JOIN SHOWNAT sa ON sa.theatrename = t.name
JOIN MOVIES m ON m.title = sa.movietitle
GROUP BY t.city, m.title
ORDER BY m_title DESC
Obviously my issue is in declaring the newest movies - how can I account for this? I learn by example - Once someone shows me one way, I can apply it to everything else - Please help.