Solution 4
1.Give the details of the authors who have 2or more books in the catalog and the price of
the books is greater than the average price of the books in the catalog.
Select * from author
where author_id in(select author_id from catalog
where price>(select avg(price)fromcatalog)
group by author_id having count(*)>=2);
2.Find the author of the book, which has maximum sales.
select a.name from author a,catalog c,order o
where a.author_id=c.author_id and o.book_id= c.book_id
and o.quantity=(select max(quantity) from order);
3.Demonstrate how you increase the price of books published by a specific publisherby10%
update catalog set price=1.1*price
where publisher_id=2002;
select*from catalog;
Write PL/SQL program illustrates how to create and call a function.👇
CREATE OR REPLACE FUNCTION calculate_area(radius NUMBER)
RETURN NUMBER IS pi CONSTANT NUMBER := 3.14159;
area NUMBER;
BEGIN
area := pi * radius * radius;
RETURN area;
END;
/
DECLARE
radius_input NUMBER := 5;
result_area NUMBER;
BEGIN
result_area := calculate_area(radius_input);
DBMS_OUTPUT.PUT_LINE('The area of a circle with radius ' || radius_input || ' is: ' || result_area); END;
/
Comments
Post a Comment