please any on can help me with this question the question is: Using the view s18
ID: 3708633 • Letter: P
Question
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 counted.
I wrote the function and it is gives me the corrct results except when I wrote select S18h7_4('sports', 0,10);
the result i got is 68 and it supposes to be 69
create view s18h7z as
select s7.film_id, f.title, c.name,
count(distinct fa.actor_id ) as num_actors, s7.sum_renters
from f s7 right join film f on ( f.film_id = s7.film_id) right join
film_actor fa on (f.film_id=fa.film_id) right join film_category fc
on (fa.film_id=fc.film_id)
left join category c on ( fc.category_id=c.category_id)
Group by f.film_id, f.title;
this is the function
delimiter //
CREATE FUNCTION S18h7_44
(vname varchar(10), min_actors INT, max_actors INT )RETURNS INT
BEGIN
DECLARE result int default 0;
select count(film_id) INTO result
From s18h7l
where vname= name
and num_actors >= min_actors
and num_actors <= max_actors;
RETURN result;
end //
delimiter ;
Explanation / Answer
-----According to my aspect, you are using S18h7_4('sports', 0,10); means 0 actor, but i hope it should be 1 actor minimum, so try with S18h7_4('sports', 1,10); I hope you get the desired result.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.