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

  • SEARCH
  • Home
  • 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 8873039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:21:58+00:00 2026-06-14T18:21:58+00:00

Basically I am doing a movie rental company database. I need to be able

  • 0

Basically I am doing a movie rental company database.
I need to be able to Give the names of movies that made more money than any other movie within their category.

Currently, I have a product table and rental table.

Product – 
Attributes: (Product_ID, Product_Title, Rating, Release_Date, Genre, Length_of_Movie, Director_Name, Key_Actor, Num_Copies)
PK – Product_ID

Rental – 
Attributes: (Rental_ID, Member_ID, Product_ID, Date_Rented, Date_Returned)
PK – Rental_ID
FK – Member_ID, Product ID

Each rental has a value of $1.00. I was able able to get the revenue of all the rentals, but I am struggling to get it by genre or category. I got the revenue as a whole by this query:

Select sum(count(Rental_ID) *1) as Revenue 
from Rental
Group by Rental_ID;       

** every rental is $1.00 so it was a simple calculation to just count how many times a unique rental number was created and multiply it by the flat fee.

I now need to break that down, and give the highest earner per genre or category. I’m completely stumped… any help would be appreciated. Thanks.

  • 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-06-14T18:22:00+00:00Added an answer on June 14, 2026 at 6:22 pm

    I haven’t test this but:

    I’d create a view to get revenue per product like so

    Create View RevenuePerProduct As
    Select
      r.Product_ID,
      Count(*) As Revenue -- as $1/rental we can just count
    From
      Rental r
    Group By
      r.Product_ID
    

    To get the maximum earnings by Genre you can utilise the view, and I’ll make another view called MaxRevenueByGenre.

    Create View MaxRevenueByGenre As
    Select
      p.Genre,
      Max(rpp.Revenue) As MaxByGenre
    From 
      RevenuePerProduct rpp
        Inner Join
      Product p
        On rpp.Product_ID = p.Product_ID
    Group By
      p.Genre
    

    To get the product (or products) that had the maximum revenue per genre is a bit more tricky as you need to refer to the revenue part twice. You’ll notice both views are used.

    Select
      best.Genre,
      best.ProductTitle,
      rpp.Revenue
    From
      Product best
        Inner Join
      RevenuePerProduct rpp
        On best.Product_ID = rpp.Product_ID
        Inner Join 
      MaxRevenueByGenre mpg
        On best.Genre = mpg.Genre And rpp.Revenue = mpg.MaxByGenre
    

    This will produce more than one result for each Genre if they are tied for highest earner.

    You can get by without views, by substituting the select statements of the view inside parenthesis if you prefer.

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

Sidebar

Related Questions

I'm doing this project for university, which is basically a movie database and for
I am basically doing a tutorial but my program seems to have errors that
So basically I have a GridWorld Project that I'm doing right now in my
Ok, so I'm doing a small tool that basically wipes the document properties of
I am currently doing some work for a company that runs a legacy web
Man, pointers continue to give me trouble. I thought I understood the concept.(Basically, that
I am basically doing a demo so don't ask why. It's very easy to
I'm setting up a C++ project, on Ubuntu x64, using Eclipse-CDT. I'm basically doing
I'm basically just doing some tests to figure out a good way to write
Why isn't my if-statement working? It doesn't accept NSCFStrings... Basically I'm doing this: if

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.