You are on page 1of 2

1.

SELECT cus2.*, count(inventory_id), return_date FROM


(select * from customer where customer.store_id =2) cus2
join rental using(customer_id)
where
return_date is null or extract(year_month from return_date) >200602
group by cus2.customer_id
2.
a.
SELECT * FROM film_text
WHERE description like '%drama%teacher%' or description like
'%teacher%drama%'
b.
SELECT * FROM film_text
WHERE MATCH(description) AGAINST('drama') and MATCH(description)
AGAINST('teacher')
3.
SELECT * FROM film_text
WHERE MATCH(description) AGAINST('Mad Scientist')
4.
C1.
select title, count(inventory_id), rental_date from rental
join
(select * from inventory
join film_text using(film_id)) inven_film
using(inventory_id)
where extract(year_month from rental_date) =200602
group by film_id
order by count(inventory_id) desc
limit 10
C2.
select film_text.film_id, film_text.title, rental.rental_date, count(inventory_id)
from inventory
join film_text using(film_id)
join rental using(inventory_id)
where extract(year_month from rental_date)=200602
group by film_id
order by count(inventory_id) desc
limit 10
5.
select store.*, count(inventory_id) as numDisc from store
join rental
on manager_staff_id =staff_id
where extract(year_month from rental_date) =200602
group by store_id
order by numDisc desc
6.
select count(*) from inventory
where inventory.film_id = (select film_id from film_text where title='AGENT
TRUMAN')
and store_id=1

You might also like