Question

USING SQL 4. Show me the maximum rental duration and minimum rental duration from the film...

USING SQL

4. Show me the maximum rental duration and minimum rental duration from the film table. Name the columns MaxRentalDuration and MinRentalDuration respectively.

5. List the actor ID, last name, and first name of each actor and the count of films (name column FilmCount) each is in for those actors who acted in more than 35 films. Order results by FilmCount. (Hint: You will need to use GROUP BY and HAVING in your query.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution :

Query 1:

SELECT MAX(rental_duration) as MaxRentalDuration,MIN(rental_duration) as MinRentalDuration from film;

Explanation:

Here we are retrieving maximum and minimum rental_durations from film table by using Aggregate functions.

Query 2:

select a.actor_id,a.first_name,a.last_name,b.FilmCount from actor a join (select actor_id,count(film_id) as FilmCount from film_actor group by actor_id having count(film_id)>35)b on a.actor_id=b.actor_id order by b.FilmCount;

Explanatoin:

Here we are counting the film_ids by grouping actor_ids and then we are filtering only the count(film_id)s greater than 35 by using having clause.

After that we are joining that result with actor table to get the first and last names of actor.

Finally sorting or arranging the records based on count(film_id)

Code and Output Screenshots:

Note : While displaying records in the table displayed only top 10 rows since the table contains huge data it is not possible to show entire one.if we want to see the data then check the film,actor,film_actor tables in sakila database in MySQL. Sakila database is a default database comes with MySQL Software.

Note : if you have any queries please post a comment thanks a lot..always available to help you

Add a comment
Know the answer?
Add Answer to:
USING SQL 4. Show me the maximum rental duration and minimum rental duration from the film...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • Need MySql commands for Use a UNION statement. Display the address ID, address, and district from...

    Need MySql commands for Use a UNION statement. Display the address ID, address, and district from the address table where the district is California or Alberta. Display the address ID, address, and district only from the address table where the address contains Jol. Display the language ID and name from the language table and the film ID from the film table. Display all languages whether they have an associated film or not. Order results by language ID in ascending order....

  • I need help with certain questions. Please. 18. 4 points For each Rental, list the Rental...

    I need help with certain questions. Please. 18. 4 points For each Rental, list the Rental ID, Rental date, customer ID, customer first name, customer last name, and count of disks rented; sort by Rental ID. Show the Rental date formatted as ‘mm-dd-yyyy.’ Hint: use a GROUP BY clause. 19. 4 points List the disk ID, title name, rating, format description, and fee amount for all copies rented in Rental 3; sort by disk ID. Show the fee amount formatted...

  • In this assignment you will combine HTML, PHP, and SQL in order to create a web...

    In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies. Task 1 Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the...

  • 2) What were the total rental fees for each member by member last name? (w3schools-> SQL...

    2) What were the total rental fees for each member by member last name? (w3schools-> SQL Inner Join& SQL Functions Count, Avg, Sum & SOL Group By)- this requires 2 joins 13) What were the total rental fees for members treport Mem num who total fees were greater than $5-change the output label to FeesMoreThan5S? (w3schools->SQL Inner Join & SQL Functions Count, Avg, Sum& SQL Group By & SQL Having) 14) What was the highest fee paid by each member...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • Using SQL*Plus on OMEGA, access the tables you created in Project 2 and complete the following...

    Using SQL*Plus on OMEGA, access the tables you created in Project 2 and complete the following SQL transactions. Log your statements and results by spooling your file (with echo on). Directions for creating and running SQL files are available in the Assignments and Exams page in Blackboard (in the Project 2 group of files). All column headings must show in their entirety. Be sure to include a cover sheet with your full name, section, and date submitted. 19. 4 points...

  • Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587...

    Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587 When all of your queries are complete, cut and paste the SQL Syntax into a word document. In order to see what the column names are, you need to click on the table and then Columns to see the field names. Make sure to include column headings that make sense in the queries (use the as “Field Name” after the field selected). Multi-table Queries...

  • please any on can help me with this question the question is: Using the view s18h7z,...

    please any on can help me with this question the question is: Using the view s18h7z, write a function S18h7_4 that counts the number of films in a category within a specific range of number of actors. It takes three parameters: 1. Category: the name of a category 2. min_actors: the minimum number of actors a film must have in order to be counted. 3. min_actors: the maximum number of actors a film must not exceed in order to be...

  • Consider the table actor which already exists in our database, with 200 rows. Upon executing SHOW...

    Consider the table actor which already exists in our database, with 200 rows. Upon executing SHOW CREATE TABLE `actor`, we get the following: CREATE TABLE `actor` ( `actor_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(10) NOT NULL, `last_name` varchar(10) NOT NULL, `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`actor_id`), KEY `idx_actor_last_name` (`last_name`) ) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8 You will need this table for any questions below which refer to an `actor` table. 1. Using the actor...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT