Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1061047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:25:10+00:00 2026-05-16T18:25:10+00:00

So I’ve been doing this all night – can’t quite understand my homework, and

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:25:10+00:00Added an answer on May 16, 2026 at 6:25 pm

    The question is really poor, because the only way to know what is “newest” is by the MOVIE.releasedate value, which will be the same for all cities because the release date should’ve been stored in the SHOWNAT table for each combination of city & movie.

    This will list all the movies in the database, the newest movie at the top:

      SELECT m.title,
             t.city
        FROM THEATRES t
        JOIN SHOWNAT sa ON sa.theatrename = t.name
        JOIN MOVIES m ON m.title = sa.movietitle
    ORDER BY m.releasedate DESC, m.title, t.city
    

    To get only the newest movies, I’d use analytic functions (supported 8i+, but likely beyond the scope of your class):

      SELECT x.city, 
             x.title             
        FROM (SELECT t.city,
                     m.title,
                     ROW_NUMBER() OVER(PARTITION BY t.city
                                           ORDER BY m.releasedate) AS rank
                FROM THEATRES t
                JOIN SHOWNAT sa ON sa.theatrename = t.name
                JOIN MOVIES m ON m.title = sa.movietitle) x
       WHERE x.rank = 1
    ORDER BY x.city, x.title
    

    To get more than the topmost movie, change WHERE x.rank = 1 to:

    WHERE x.rank <= 3
    

    …to get the top three most recently released movies. Change to suit your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.