Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE
- maxPrice movie.price%TYPE;
- maxCount NUMBER(4);
- maxTitle movie.title%TYPE;
- maxStar movie.star%TYPE;
- BEGIN
- SELECT MAX(price) INTO maxPrice FROM movie;
- DBMS_OUTPUT.put_line('The most expensive movie costs Rs.'|| maxPrice);
- SELECT COUNT(mv_no) INTO maxCount FROM movie WHERE price = maxPrice;
- IF (maxCount != 1) THEN
- DBMS_OUTPUT.put_line(maxCount||' movies are priced at Rs.'||maxPrice);
- ELSE
- SELECT title, star INTO maxTitle,maxStar FROM movie WHERE price = maxPrice;
- DBMS_OUTPUT.put_line('The most expensive movie is '||maxTitle||' staring '||maxStar||'.');
- END IF;
- END;
- /
Add Comment
Please, Sign In to add comment