Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEED SQL COMMANDS FOR: 1. Using the payment table find all of the payments made

ID: 3605297 • Letter: N

Question

NEED SQL COMMANDS FOR:

1. Using the payment table find all of the payments made by customer 7 (you will get one number).

2. Using the actor table, find ALL of the actors that have the first name “Ed”. List the actor id, first name, and last name in ascending order by last name.

3. Using the Country table, count the number of countries in the list (you will get 1 number).

4. Using the Film table, find out how many rentals had a rental duration of 5 or more days, and list the film’s Title, Description, and the number of days rented. Sort by title, ascending.

5. Using the Film category table, find out how many films had a category ID of 14 (you will get 1 number).

6. Using the Rental table, select all rentals that occurred before 08-01-2005. List Rental_Date, Inventory_ID, Customer_ID and Staff_ID. Order by Customer_ID then by Rental_Date.

7. Using the Customer and the Address table (you will need to Join the tables), list the customer_id, first_name, last_name, address, district, city_id, postal_code, phone, and email. Join on the address_id from both tables. Order by last_name then first_name.

8. Using the Customer and the Address table (you will need to Join the tables), list the customer_id, first_name, last_name, address, district, city_id, postal_code, phone, and email for those customers that live in California. Join on the address_id from both tables. Order by last_name then first_name.

9. Using the Customer and the Address table (you will need to Join the tables), list the customer_id, first_name, last_name, address, district, city_id, postal_code, phone, and email where the city_id is greater than 500. Join on the address_id from both tables. Order by city_id.

10. Using the actor and film_actor table, join using the actor_id field from both tables. List the actor_id, first_name, last_name, and film_id. Order by film_id, actor_id

Explanation / Answer

1.

SELECT         *

FROM             PAYMENT

WHERE          CUSTOMER_ID = 7

2.

SELECT         id, fname, lname

FROM             ACTORS

WHERE          fname = “Ed”

ORDER BY   lname ASC

3.

SELECT         COUNT(*)

FROM             COUNTRY

4.

SELECT         title, description, daysrented

FROM                         FILM

WHERE          duration >= 5

ORDER BY title      ASC

5.

SELECT         COUNT(ID)

FROM             FILM

WHERE          ID=14