Вы находитесь на странице: 1из 1

0.

create table st_book(all_no number(3),book_name varchar2(20),author varchar2(20),year_of_publisher


date,publisher varchar2(20),type varchar2(20));
1. Retrive the name of other from the table of book;
2.Give the names of books of classics, classics written by YPK;
3. List the book name,author and year of publish for all the books which are ten years old.
-->select book_name,author,year_of_publisher from st_book where (sysdate-year_of_publisher)>1800;
SQL> select book_name,author,year_of_publisher from st_book where (sysdate-year_of_publisher)>1800;
BOOK_NAME
AUTHOR
YEAR_OF_P
-------------------- -------------------- -------------------------c
vengopal
12-MAY-99
m3
bs
12-FEB-99
adc
bplathi
15-FEB-98
m2
bs
12-MAY-00
SQL>
4. Alter table add column no.of copy sold.
alter talbe st_book add column no_copy number(8);
5. list the no. of books in ascending order in max no.of copy sold .
select max(no_copy) from st_book;
select book_name from st_book order by no_copy desc;
SQL>

select book_name from st_book order by no_copy desc;

BOOK_NAME
-------------------classics
c
m2
m3
adc
ALL_NO BOOK_NAME
AUTHOR
YEAR_OF_PUBLISHER
TYPE
NO_COPY
-------------------- -------------------- ------------------------------ -------------------- -----------------------------------------105 adc
bplathi
15-FEB-98 tata_mc
electronics
1
106 m2

bs

12-MAY-00 shri

mathematics

6. list the name of top three best saler.


select *from st_book (select book_name from st_book order by no_copy desc) where rownum<4;
SQL> select *from st_book where rownum<4;
ACC_NO
BOOK_NAME
AUTHOR
YEAR_OF_PUBLISHER
TYPE
NO_COPY
-------------------- -------------------- --------------------------------------------------------------------------------------------101
classics
ypk
12-JUN-12 bpb
programming
5
102

103

m3

vengopal
bs

12-MAY-99 bpb
12-FEB-99

shri

programming

mathematics

Вам также может понравиться