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

SQL Homewonk Using MySOL Assignment 4 COP3703 Instructions: Prepare and execute

ID: 3731853 • Letter: S

Question

SQL Homewonk Using MySOL Assignment 4 COP3703 Instructions: Prepare and execute each of the queries listed using the "sakila" database in MySQL Use the schema shown below. When all of your queries are complete, follow the instructions below to prepare your homework Preparing your homework for subnuission: 1 Type your queries into the query window of AfySQL 2ecute the queries. Scroll trough the output windowtobe sure there arenoemors 3. Copy your SQL syntay and then take a screen shot of your output (resuits) and insert into your document for subaission. errors in the indivicual query from your Word file, then go back to Step 1 at the top. This is what you will tum in for Assignment 4 in CANVAS. 4. If there are no errors in your output, coutimve to the pext step. If there are errors correct the 5. Execute the queries again 6. Make sure to copy and paste ALL queries into a Word RTF, or PDF docment put your name Schema Entities for the Sakila Database

Explanation / Answer

--1

SELECT actor_id AS 'Actor ID',

first_name AS 'First Name',

last_name AS 'Last Name'

FROM actor

ORDER BY last_name ASC;

--2

SELECT address AS Address,

district AS District,

city_id AS 'City ID',

postal_code AS 'Postal Code'

FROM address

ORDER BY district,city_id

--3

SELECT address AS Address,

district AS District,

city_id AS 'City ID',

postal_code AS 'Postal Code'

FROM address

WHERE location='England';

--4

SELECT name FROM category ORDER BY name DESC;

--5

SELECT first_name,

last_name,

email

FROM customer

ORDER BY last_name,first_name;

--6

SELECT title,

description,

release_year,

rental_rate,

length,

replacement_cost

FROM film

WHERE length > '100';

ORDER BY length DESC

--7

SELECT payment_id,

customer_id,

staff_id,

rental_id,

amount,

payment_id

FROM payment

WHERE amount='2.99'/*please replace if wrong*/

ORDER BY customer_id,amount ASC;

--8

SELECT rental_id,

rental_date,

inventory_id,

customer_id,

return_date

FROM rental

WHERE customer_id=36

ORDER BY inventory_id ASC;

--9

SELECT rental_id,

rental_date,

inventory_id,

customer_id,

return_date

FROM rental

WHERE customer_id in (12,19,26)

ORDER BY customer_id,inventory_id;

--10

SELECT COUNT(film_id) FROM film_actor

WHERE actor_id IN (8,15,27,31);

--11

SELECT * FROM payment WHERE customer_id=7;

--12

SELECT actor_id AS 'Actor ID',

first_name AS 'First Name',

last_name AS 'Last Name'

FROM actor

WHERE first_name='Ed'

ORDER BY last_name ASC;

--13

SELECT COUNT(Country) AS NumberOFcountry FROM country;

--14

SELECT title,

description,

rental_duration

FROM film

WHERE rental_duration >=5

ORDER BY title ASC;

--15

SELECT COUNT(film_id) As filmCount FROM film_category WHERE category_id=14;

--16

SELECT  

rental_date,

inventory_id,

customer_id,

staff_id

FROM rental

WHERE rental_date < '08-01-2005'

ORDER BY customer_id,rental_date;

--17

SELECT c.customer_id,

c.first_name,

c.last_name,

a.address,

a.district,

a.city_id,

a.postal_code,

c.email

FROM customer c INNER JOIN address a

ON c.address_id=a.address_id

ORDER BY c.first_name,c.last_name;

--18

SELECT c.customer_id,

c.first_name,

c.last_name,

a.address,

a.district,

a.city_id,

a.postal_code,

c.email

FROM customer c INNER JOIN address a

ON c.address_id=a.address_id

WHERE a.location='california'

ORDER BY c.first_name,c.last_name;

--19

SELECT c.customer_id,

c.first_name,

c.last_name,

a.address,

a.district,

a.city_id,

a.postal_code,

c.email

FROM customer c INNER JOIN address a

ON c.address_id=a.address_id

WHERE a.city_id>500

ORDER BY a.city_id;

--20

SELECT a.actor_id,

a.first_name,

a.last_name,

f.film_id

FROM actor a INNER JOIN film_actor f

ON a.actor_id=f.actor_id

ORDER BY f.film_id,a.actor_id;

/**please comment if you have any doubt**/

/**Thanks You**/