Saved Bookmarks
| 1. |
Write SQL commands for the queries given from a to f and write the output of the SQL commands given in part g based on a table LIBRARY shown below:(a) To display the title of all books with Price between 100 and 300.(b) To display Title and Author of all the books having type Prog and published by BPB. (c) To display the list of all the books with price more than 130 in ascending order of Qty.(d) To display the list of all books whose quantity is less than 4.(e) To display the publishers and the number of books of each book in the table.(f) To insert a new book in the table LIBRARY.(g) To increase the price of the book title ‘TURBO C++’ by Rs.30.(h) To display the Title and Total Price of all Computer books. The Total Price is calculated as Price * Qty.(i) Write the output of the following:(i) Select MIN(Price) from Library;(ii) Select Sum(Price * Qty) from Library where Qty > 3;(iii) Select Avg(Price) from Library where Qty < 4;(iv) Select Count(Distinct Publisher) from Library |
|
Answer» (a) SELECT Title FROM LIBRARY WHERE (Price BETWEEN 100 AND 300); (b) SELECT Title, Author FROM LIBRARY WHERE (Subject=’Prog’ AND Publisher=‘PBP’); (c) SELECT * FROM LIBRARY WHERE Price>130 ORDER BY QUANTITY ASC; (d) SELECT * FROM LIBRARY WHERE Quantity<4; (e) SELECT Publisher, Quantity FROM LIBRARY; (f) INSERT INTO LIBRARY VALUES (11,’Question Bank’, ‘Expert’, ‘IP’, ‘Oswaal Books’,10,150); (g) UPDATE LIBRARY, SET Price = Price+30 WHERE Title = ‘TURBO C++’; (h) SELECT Title, Price*Quantity FROM LIBRARY; (i) 40.00 (ii) 1620 (iii) 143 (iv) 7 |
|