ASSISNMENT:1TABLE CREATION:1. create table course(course_no char(4) primary key,course_namevarchar(20));2. create table co...
insert into course_fee values(c2,F,8000);insert into course_fee values(c3,P,12000);insert into course_fee values(c4,P,1400...
insert into course_taken values(32345,c2,30-SEPTEMBER-2010,F,FN,GOOD);insert into course_taken values(42345,c3,28-SEPTEMBE...
Q3. Find the names of students starting with A.select *from studentwhere name like A%;no rows selectedQ4. Print the names ...
Q6. Determine the maximum and minimum course fees.select max(fees),min(fees)from course_fee; MAX(FEES) MIN(FEES)----------...
29-september-201030-september-201030-september-201028-september-201030-september-2010Q10. Find out in which course maximum...
2000. Q13. Find out in which course maximum number of students have takenadmission in the current month.select course.cour...
ASSIGNMENT 1
Upcoming SlideShare
Loading in...5
×

Sql

718

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
718
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Sql

  1. 1. ASSISNMENT:1TABLE CREATION:1. create table course(course_no char(4) primary key,course_namevarchar(20));2. create table course_fee(course_no char(4) unique,full_part char(1),feesnumber(10),foreign key(course_no) references course);3. create table student(prospectus_no number(10) primary key,namevarchar(20),address varchar(30),phone_no number(11),D_O_B date,total_amtnumber(10,2),amt_paid number(10,2),installment char(1));4. create table installment(prospectus_no number(10)unique,installment_amt number(10,2),due_dt date unique,paidchar(1),foreign key(prospectus_no) references student on delete cascade);5. create table course_taken(prospectus_no number(10),course_nochar(4),start_dt date,full_part char(1),time_slot char(2),performancevarchar(20),foreign key(prospectus_no) references student,foreignkey(course_no) references course);INSERTING VALUES:1. insert into course values(c1,LINUX);insert into course values(c2,UNIX);insert into course values(c3,ORACLE);insert into course values(c4,JAVA);2. insert into course_fee values(c1,F,10000);
  2. 2. insert into course_fee values(c2,F,8000);insert into course_fee values(c3,P,12000);insert into course_fee values(c4,P,14000);3. insert into student values(12345,student1,address1,123456,01-JANUARY-1990,20000,10000,I);insert into student values(22345,student2,address2,223456,02-FEBRUARY-1990,20000,20000,F);insert into student values(32345,student3,address3,323456,03-MARCH-1990,10000,8000,I);insert into student values(42345,student4,address4,423456,04-APRIL-1990,12000,12000,F);insert into student values(52345,student5,address5,523456,05-MAY-1990,12000,10000,I);4. insert into installment values(12345,5000,22-AUGUST-2010,U);insert into installment values(22345,20000,23-AUGUST-2010,P);insert into installment values(32345,2000,24-AUGUST-2010,U);insert into installment values(42345,12000,24-SEPTEMBER-2010,P);insert into installment values(52345,1000,29-SEPTEMBER-2010,U);5. insert into course_taken values(12345,c1,29-SEPTEMBER-2010,F,AN,GOOD);insert into course_taken values(22345,c1,30-SEPTEMBER-2010,F,FN,GOOD);
  3. 3. insert into course_taken values(32345,c2,30-SEPTEMBER-2010,F,FN,GOOD);insert into course_taken values(42345,c3,28-SEPTEMBER-2010,P,AN,GOOD);insert into course_taken values(52345,c4,30-SEPTEMBER-2010,P,AN,GOOD);QUERIES:Q1. Retrieve name and course no. of all students.select student.name,course_taken.course_no from student,course_taken where student.prospectus_no=course_taken.prospectus_no;NAME COUR-------------------- ----student1 c1student2 c1student3 c2student4 c3student5 c4Q2. List the names of students who have paid the full amount at the time ofadmissionselect name from student where total_amt=amt_paid;NAME--------------------student2student4
  4. 4. Q3. Find the names of students starting with A.select *from studentwhere name like A%;no rows selectedQ4. Print the names of students whose total amount is not equal to amountdue.select student.namefrom studentwhere amt_paidnot in(select amt_paid from student where total_amt=amt_paid);NAME--------------------student1student3student5Q5. Count the number of students who have joined in current year, currentmonth.select count(*) from course_taken where start_dt like ___SEP_10; COUNT(*) ---------- 5
  5. 5. Q6. Determine the maximum and minimum course fees.select max(fees),min(fees)from course_fee; MAX(FEES) MIN(FEES)----------- --------- 14000 8000Q7. Increase the fee of Oracle by 50%.update course_feeset fees=1.5*feeswhere fees in(select course_fee.fees from course_fee,coursewhere course.course_no=course_fee.course_no andcourse.course_name=ORACLE);Q8. Print the details of courses whose fees are between 5000 and 10000.selectcourse.course_no,course.course_name,course_fee.fees,course_fee.full_part from course,course_fee where course.course_no=course_fee.course_no and (course_fee.fees>5000and course_fee.fees<10000);COUR COURSE_NAME FEES F---- -------------------- ---------- -c2 UNIX 8000 FQ9. Display the admission date in DD-MONTH-YY formatselect TO_CHAR(start_dt,dd-month-yyyy)as start_dtfrom course_taken;START_DT-----------------
  6. 6. 29-september-201030-september-201030-september-201028-september-201030-september-2010Q10. Find out in which course maximum number of students have takenadmission.select course.course_name from course,course_taken where course.course_no=course_taken.course_no group by course.course_name having count(course_taken.prospectus_no)>=all (select count(prospectus_no) from course_taken group by course_no);COURSE_NAME--------------------LINUXQ11. Change the course_name from Unix to Unix OS.update courseset course_name=UNIX OSwhere course_name=UNIX;Q12. Get the sum of amount to be collected from students in this month.select sum(student.total_amt-student.amt_paid)from student,installmentwhere student.prospectus_no=installment.prospectus_noand installment.due_dt like ___SEP_10;SUM(STUDENT.TOTAL_AMT-STUDENT.AMT_PAID)---------------------------------------
  7. 7. 2000. Q13. Find out in which course maximum number of students have takenadmission in the current month.select course.course_namefrom course,course_takenwhere course.course_no=course_taken.course_no and start_dt like___SEP_10group by course.course_namehaving count(course_taken.prospectus_no)>=all(select count(prospectus_no) from course_taken group by course_no);COURSE_NAME--------------------LINUXQ14. Select the students who have not yet paid full amount of fees.select namefrom studentwhere total_amt>amt_paid;NAME--------------------student1student3student5
  8. 8. ASSIGNMENT 1

×