1. The document describes creating tables to store data about courses, fees, students, installments, and courses taken. It provides SQL commands to create the tables and insert sample data.
2. It then lists a number of queries against the tables including retrieving student and course details, finding students who paid in full, and updating course names and fees.
3. The queries help demonstrate different SQL functions like aggregation, filtering, joins, formatting dates, and updating records.
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. 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 c1
student2 c1
student3 c2
student4 c3
student5 c4
Q2. List the names of students who have paid the full amount at the time of
admission
select name
from student
where total_amt=amt_paid;
NAME
--------------------
student2
student4
4. Q3. Find the names of students starting with A.
select *
from student
where name like 'A%';
no rows selected
Q4. Print the names of students whose total amount is not equal to amount
due.
select student.name
from student
where amt_paid
not in(select amt_paid from student where total_amt=amt_paid);
NAME
--------------------
student1
student3
student5
Q5. Count the number of students who have joined in current year, current
month.
select count(*)
from course_taken
where start_dt like '___SEP_10';
COUNT(*)
----------
5
5. Q6. Determine the maximum and minimum course fees.
select max(fees),min(fees)
from course_fee;
MAX(FEES) MIN(FEES)
----------- ---------
14000 8000
Q7. Increase the fee of Oracle by 50%.
update course_fee
set fees=1.5*fees
where fees in(select course_fee.fees from course_fee,course
where course.course_no=course_fee.course_no and
course.course_name='ORACLE');
Q8. Print the details of courses whose fees are between 5000 and 10000.
select
course.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>5000
and course_fee.fees<10000);
COUR COURSE_NAME FEES F
---- -------------------- ---------- -
c2 UNIX 8000 F
Q9. Display the admission date in DD-MONTH-YY format
select TO_CHAR(start_dt,'dd-month-yyyy')
as start_dt
from course_taken;
START_DT
-----------------
6. 29-september-2010
30-september-2010
30-september-2010
28-september-2010
30-september-2010
Q10. Find out in which course maximum number of students have taken
admission.
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
--------------------
LINUX
Q11. Change the course_name from Unix to Unix OS.
update course
set course_name='UNIX OS'
where 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,installment
where student.prospectus_no=installment.prospectus_no
and installment.due_dt like '___SEP_10';
SUM(STUDENT.TOTAL_AMT-STUDENT.AMT_PAID)
---------------------------------------
7. 2000
.
Q13. Find out in which course maximum number of students have taken
admission in the current month.
select course.course_name
from course,course_taken
where course.course_no=course_taken.course_no and start_dt like
'___SEP_10'
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
--------------------
LINUX
Q14. Select the students who have not yet paid full amount of fees.
select name
from student
where total_amt>amt_paid;
NAME
--------------------
student1
student3
student5