Q. Write SQL commands for the following on the basis of given table :




(a) Select all the PROG type published by BPB from Library.

(b) Display a list of all books with Price more then 130 and sorted by Qty.

(c) Display all the books sorted by Price in ascending order.


Answer  =

(a)
Select * from library
Where type = ‘PROG’ AND pub = ‘BPB’ ;

(b)
Select title from library
Where price >130
Order by Qty;

(c)
Select title from  library
Order by price ;

18 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Replies
    1. 3rd is correct.
      In MySQL Default sorting is in ascending order.

      Delete
    2. Good job sir thakyou for helping๐ŸŒš

      Delete
  2. 1. To create the above table structure with proper constraints.
    5. Display a report. Listing Book No. current value and misplacement charges for each book in the above
    table. Calculate the misplacement charges for all books Price*1.25
    6. Count the number of books published by PHI
    8. Count the no of books in each Type.
    9. Add one more attribute “No_of_copies” in the above table.
    10. Update the new attribute value with 2 for each book.
    11. Count the total number of Publishers.
    can u please help me by giving this answer?

    ReplyDelete
    Replies
    1. 5. SELECT Listing Book No, price ,price*1.25 as misplacement chargesFROM library ;

      6.SELECT COUNT(*) FROM library WHERE pub="PHI";

      9. ALTER TABLE library ADD no_of_copies int;

      Delete
  3. In the third part of this question why Asc is not written

    ReplyDelete
    Replies
    1. Because order by clause has default value 'asc'

      Delete
  4. Why it's not written select title in b and c part as in question they have written display name of book .I am confusing .can u please give my answer..

    ReplyDelete
    Replies
    1. Because I have written * which mean to display all data.

      Delete
    2. But we just have to display the names....not all records??

      Delete
  5. It's just a different model of question to be asked But , Don't worry answers will be same for everything.

    ReplyDelete
  6. In C part Ascending is not used

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post