1. Create a table named admission_detail with attribute AID, Reg.no, DOB, Program Name, DOA.
Create table admission(AID int primary key, Reg_no int, name char(20), DOB date, Program_name char(20), DOA date)
insert into admission values(5896,101,'Raj','20-jan-89','Bcom','02-Feb-14')
insert into admission values(5897,102,'Raju','21-Mar-90','BBA','03-Jan-14')
insert into admission values(5898,103,'Rajan','26-Jul-90','IT','05-Jan-14')
insert into admission values(5899,104,'Ram','25-Jul-90','BBAIT','07-Jan-14')
insert into admission values(5895,105,'Ramu','29-Dec-76','BBA','07-Jan-14')
Admission
2.Change the program name from BBA to BBAIT for AID 5896.
Create table admission(AID int primary key, Reg_no int, name char(20), DOB date, Program_name char(20), DOA date)
insert into admission values(5896,101,'Raj','20-jan-89','Bcom','02-Feb-14')
insert into admission values(5897,102,'Raju','21-Mar-90','BBA','03-Jan-14')
insert into admission values(5898,103,'Rajan','26-Jul-90','IT','05-Jan-14')
insert into admission values(5899,104,'Ram','25-Jul-90','BBAIT','07-Jan-14')
insert into admission values(5895,105,'Ramu','29-Dec-76','BBA','07-Jan-14')
Admission
AID | REG_NO | NAME | DOB | PROGRAM_NAME | DOA |
---|---|---|---|---|---|
5896 | 101 | Raj | 20-JAN-89 | Bcom | 02-FEB-14 |
5897 | 102 | Raju | 21-MAR-90 | BBA | 03-JAN-14 |
5898 | 103 | Rajan | 26-JUL-90 | IT | 05-JAN-14 |
5899 | 104 | Ram | 25-JUL-90 | BBAIT | 07-JAN-14 |
5895 | 105 | Ramu | 29-DEC-76 | BBA | 07-JAN-14 |
2.Change the program name from BBA to BBAIT for AID 5896.
update admission
set program_name='BBAIT'
where AID=5896
AID | REG_NO | NAME | DOB | PROGRAM_NAME | DOA |
---|---|---|---|---|---|
5896 | 101 | Raj | 20-JAN-89 | BBAIT | 02-FEB-14 |
5897 | 102 | Raju | 21-MAR-90 | BBA | 03-JAN-14 |
5898 | 103 | Rajan | 26-JUL-90 | IT | 05-JAN-14 |
5899 | 104 | Ram | 25-JUL-90 | BBAIT | 07-JAN-14 |
5895 | 105 | Ramu | 29-DEC-76 | BBA | 07-JAN-14 |
3.Display age of all student.
select (months_between('29-Dec-76',DOB)/12) from admission
(MONTHS_BETWEEN('29-DEC-76',DOB)/12) |
---|
-12.05914 |
-13.228495 |
-13.575269 |
-13.572581 |
0 |
4.Add column program code?
alter table admission
add program_code int
AID | REG_NO | NAME | DOB | PROGRAM_NAME | DOA | PROGRAMME_CODE |
---|---|---|---|---|---|---|
5896 | 101 | Raj | 20-JAN-89 | BBAIT | 02-FEB-14 | |
5897 | 102 | Raju | 21-MAR-90 | BBA | 03-JAN-14 | |
5898 | 103 | Rajan | 26-JUL-90 | IT | 05-JAN-14 | |
5899 | 104 | Ram | 25-JUL-90 | BBAIT | 07-JAN-14 | |
5895 | 105 | Ramu | 29-DEC-76 | BBA | 07-JAN-14 |
5.Calculate the year between DOB and DOA.
select (months_between(DOB,DOA)/12) from admission
(MONTHS_BETWEEN(DOB,DOA)/12) |
---|
-25.034946 |
-23.784946 |
-23.443548 |
-23.451613 |
-37.024194 |
6. How to view the table.
select * from Admission
No comments:
Post a Comment