Shailrshah

Name and Star of the Costliest Movie Ticket

Oct 27th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.60 KB | None | 0 0
  1. DECLARE
  2.     maxPrice    movie.price%TYPE;
  3.     maxCount    NUMBER(4);
  4.     maxTitle    movie.title%TYPE;
  5.     maxStar     movie.star%TYPE;
  6. BEGIN
  7.     SELECT MAX(price) INTO maxPrice FROM movie;
  8.     DBMS_OUTPUT.put_line('The most expensive movie costs Rs.'|| maxPrice);
  9.     SELECT COUNT(mv_no) INTO maxCount FROM movie WHERE price = maxPrice;
  10.     IF (maxCount != 1) THEN
  11.         DBMS_OUTPUT.put_line(maxCount||' movies are priced at Rs.'||maxPrice);
  12.  
  13.     ELSE
  14.         SELECT title, star INTO maxTitle,maxStar FROM movie WHERE price = maxPrice;
  15.         DBMS_OUTPUT.put_line('The most expensive movie is '||maxTitle||' staring '||maxStar||'.');
  16.     END IF;
  17. END;
  18. /
Add Comment
Please, Sign In to add comment