Question

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.

  1. 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 the city or postal code for this question).
  2. Same as #5, but only list the customers who are inactive, and include the city, country, postal code for each customer as well.
  3. Add 2 rows to the Film Database before working on this query. These new films are the only results you should get.

Use this script to insert the new record.

INSERT INTO sakila.film (film_id,title,description,release_year,language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features)

VALUES (1001,'1st Grade FBI Agent','An undercover FBI agent must pretend to be a 1st grade teacher to catch the bad guy',2014,2,5,4.99,123,20.99,'PG-13','trailers'),

(1002,'2nd Grade DEA Agent','An undercover DEA agent must pretend to be a 2nd grade teacher to catch the bad guy',2015,3,4,5.99,132,16.99,'PG-13','trailers');

Write a query that produces the title and description of all films that are not in English.

  1. Write a query that produces the title, rental rate, and language for all Sci-Fi films.
  2. Write a query that produces a count of the number of   Action films(distinct titles, not copies of films)
  3. Same as #9, but look at the inventory – so if there are 2 copies of a film it needs to be counted twice.
  4. Write a query that produces the title and rental duration of all films that have a replacement cost between $15 and $23 (inclusive).
  5. Write a query that produces the title of every action film with a rating of PG-13, R, or NC-17.
  6. Write a query that produces the average length of all Children movies.
  7. Write a query that produces the last name and first name and film title of all actors who are in Family, Foreign, or Horror films ordered by last name
  8. Write a query that produces the last name and first name and film title and film category of every actor who is in either a Family movie OR a Horror movie ordered by last name. rename the category from “name” to “category” in your result table. (hint: “AS” keyword)
  9. Write a query that produce the last name and email address of every customer who has rented a film starring NICK WAHLBERG or MATTHEW JOHANSSON or RITA REYNOLDS (we don’t want to have duplicate rows returned for our query – there is a keyword you might need to use).
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

This demonstration is using WAMP server.

Question :

SQL Query :

select last_name,first_name,address,district,phone from
customer,address where
customer.address_id=address.address_id;

Screen in PHPMyAdmin :

Server phpMyAdmin demo - MySQL Database: sakila»Table: address Search Insert Imp SQL Browse Structure Export are not availablServer phpMyAdmin demo - MySQL Database: sakila»Table: address Search Insert Imp SQL Browse Structure Export are not availabl

*****************************************

Question :

SQL Query :

select last_name,first_name,address,District,phone,city,country,postal_code FROM customer,address,city,country where customer.customer_id=address.address_id and address.city_id=city.city_id and city.country_id=country.country_id and active=0

Screen in PHPMyAdmin :

Server: phpMyAdmin demo - MySQL>Database: sakila Structure SQL Search Query Export mport Operations Privileges Routines More

*****************************************

Question :

SQL Query :

select title,description from film where language_id not in (select language_id from language WHERE name='English')

Screen in PHPMyAdmin :

Database: sakila » Server phpMyAdmin demo - MySQL Table: film Browse Structure ZInsert Privileges SQL Search Export Import Sh

*****************************************

Question :

SQL Query :

/*Write a query that produces the title, rental rate, and language for all Sci-Fi films.*/
SELECT title,rental_rate,language.name from film,language,film_category,category
WHERE
film.language_id=language.language_id and
film.film_id=film_category.film_id and
film_category.category_id=category.category_id and category.name='Sci-Fi';

Screen in PHPMyAdmin :

Database: sakila» Table: language Server: phpMyAdmin demo - MySQL EInsert Browse Structure SQL Search Export Import Privilege

*****************************************

Question :

SQL Query :

select title,rental_duration from film WHERE replacement_cost BETWEEN 15 and 23;

Screen in PHPMyAdmin :

Server: phpMyAdmin demo - MySQL Database: sakila »Table: film EE Insert Browse Structure SQL Search Expc select title, rental

*****************************************

Question :

SQL Query :

/*Write a query that produces the title, rental rate, and language for all Sci-Fi films.*/
SELECT count(title) from film,film_category,category
WHERE
film.film_id=film_category.film_id and
film_category.category_id=category.category_id and category.name='Action'
GROUP by category.name;

Screen in PHPMyAdmin :

Database: sakila »Table: language Server phpMyAdmin demo - MySOL» EInsert SQL Privileges Browse Structure Search Export Impor

*****************************************

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
SQL Queries – in this assignment you will be asked to create several SQL queries relating...
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
  • 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...

  • Create the following SQL Server queries that access the Northwind database Same as problem 3 but,...

    Create the following SQL Server queries that access the Northwind database Same as problem 3 but, limit the list to all customers who placed 3 or more orders. The product id, product name, last date that the product was ordered for all items in the Grains/Cereals category. (Hint: Use MAX) The product ID, product name, and number of distinct customers who ordered that product in 1996 Thank you. Categories Customers Employees Order Details Orders Products Shippers 9 CategoryID CategoryName Description...

  • Create an ER from the following requirement. Use Chen notation with cardinality and participation notation. If...

    Create an ER from the following requirement. Use Chen notation with cardinality and participation notation. If you make an assumption that is not in the requirements, please note this on the ER. We are going to do a database for the film critic of a newspaper. The critic reviews movies and would like to keep track of the movie’s title, category (Humor, Drama, Action), and the date the movie was released. A title may have more than one category. We...

  • 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...

  • You work for a DVD rental company. Your manager has asked you to pull some data on the company, i...

    You work for a DVD rental company. Your manager has asked you to pull some data on the company, its inventory, and customers. You will complete this by developing and running SQL queries. Initialize Your Database (NOTE: If you alreody did this in Project 1, you do not need to do this step again): 1. Download RentalCompany.sql from Doc Sharing. Run the script to create tables and data. You should not receive errors. There may be a few warnings, but...

  • SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address...

    SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • CIT 214 - Homework 4 - Alexamara Marina Group Multiple Table Queries Use Notepad to create...

    CIT 214 - Homework 4 - Alexamara Marina Group Multiple Table Queries Use Notepad to create the commands that will run the following queries/problem scenarios. For every boat, list the marina number, slip number, boat name, owner number, owner's first name, and owner's last name. For every completed or open service request for routine engine maintenance, list the slip ID, description, and status. For every service request for routine engine maintenance, list the slip ID, marina number, slip number, estimated...

  • Using the database: Write SQL queries for each of the questions below. 1. Find the media...

    Using the database: Write SQL queries for each of the questions below. 1. Find the media type which has 100 or more tracks. Print the name of such media type. Number of rows returned in the result = 3 A) Find the playlists which have one or more tracks that have never been purchased in California (CA). Print the Id, and the name of such playlists. Number of rows returned in the result = 18 B) Find the customers who...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

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