Practicle File SQL Faculty: MR Surendra Namdeo
Practicle File SQL Faculty: MR Surendra Namdeo
Practicle File SQL Faculty: MR Surendra Namdeo
SQL
Submitted By :
Shiraz Khan
MCA II sem
Question 1:- Consider the relationship EMPLOYEE
Attributes are:
E_id Varchar2(20),
F_Name Varchar2(15),
M_Name Varchar2(15),
L_Name Varchar2(20),
Address Varchar2(100),
Salary Number(10,2),
Date_of_Birth Date
Answer:-
Create.sql :-
desc szk_employee;
commit;
Insert.sql :-
constraint .sql :-
Drop table.sql :-
Q2:- Get Full Names of employees, concatenate the column F_Name, M_Name and
L_Name. Rename the new column heading as ‘FULL NAME’.
Q3:- Find out the youngest and oldest person from employee table.
union
Q4:- Get employee id and name that belong to the Bhopal city.
Q5:- Get employee name and date of birth. (Date of Birth should be in format
‘DD/MM/YY HH:MI:SS’)
delete szk_employee
where substr(address, instr(address,';',1,3)+1,
instr(address,';',1,4)-(instr(address,';',1,3))-1) like 'Bhopal';
Q7:- List all the employees who are located in ‘TT NAGAR’ colony.
select * from szk_employee
where substr(address, instr(address,';',1,2)+1,
instr(address,';',1,3)-(instr(address,';',1,2))-1) like 'TT Nagar';
Q8:- Find the names of all employees having ‘S’ as the first letter in their names.
Q9:- Find the list of all employees whose salary is greater than value 10,000.
Q10:- Insert one row into employee table. Where DOB is ‘10/Dec/1987 18:20:23’.
Answer:-
Create.sql :-
commit;
insert.sql :-
foreignkey.sql:-
drop constraint.sql :-
drop table.sql:-
queries.sql :-
Q1:- List the entire client who are located in BHOPAL city.
update szk_product_master
set cost_price='948.65'
where description='1.22 Floppy';
Q3:- List the names, city and pin code of clients who are not in the state of ‘Maharastra’.
Q4:- Determine the maximum and minimum product prices, Rename the output as
Max_Rate and Min_Rate respectively.
Q7:- Print the description and total qty sold for each product.
Q8:- Find the names of clients who have purchased ‘CD Drive’.
Q10:- Find the customer_name and address for the client who has placed order no.
‘O190012’.
Q11:- Find the names of clients who have placed orders worth Rs. 10,000 or more.
Q12:- Find out the products, which have been sold to ‘AMIT’.
create.sql:-
commit;
insert.sql:-
foreignkey:-
drop constraint:-
drop table:-
drop table szk_student;
queries:-
Q.1 Retrieve the names of all senior students of (III year(V sem)) of branch ‘CA’.
select name from szk_student
where year='III';
Q.2 Retrieve the names of all subject taught by Prof. King in 1998 & 1999.
select distinct su.sub_name from
szk_subject su, szk_instructor i, szk_section se
where ((se.year='1998' or se.year='1999') and i.name='Prof. King')
and su.sub_code=se.sub_code and i.instructor_id=se.instructor_id;
Q.3 For each section taught by prof. King, retrieve the course number, semester, year.
select distinct se.secidentifer, se.sub_code, se.year, se.semester from
szk_subject su, szk_section se, szk_instructor i
where i.name='Prof. King'
and su.sub_code=se.sub_code and i.instructor_id=se.instructor_id;
Q.4 For each section find number of students who took the section.
select secidentifier, count(roll_no)”No Of Students” from szk_grade_report
group by secidentifier;
Q.5 Retieve the name and transcript of each senior student, branch in ‘CA’. A transcript
includes subject name, subject code, semester, year and grade for each subject
completed by the student.
select distinct s.name, su.sub_name, su.sub_code, s.year, se.semester,
se.year, gr.grade
from szk_student s, szk_subject su, szk_section se, szk_grade_report gr
where (s.year='II' or s.year='III') and s.roll_no=gr.roll_no and
se.secidentifer=gr.secidentifier and su.sub_code=se.sub_code
order by su.sub_code;
Q.6 Retrieve the name of student, department in which student have grade A in their
subject.
select name, branch from szk_student
where (roll_no in (select roll_no from szk_grade_report
where grade='A'));
Q.7 Create a view that has the roll no, student name and their grade.
create or replace view student_detail
as(select s.roll_no, s.name, g.grade from
szk_student s, szk_grade_report g
where (s.roll_no=g.roll_no));
Q.8 Create a view that has name of prof. who taught in 1999 and 2000.
create or replace view prof_98_99
as(select i.name, se.year from szk_instructor i, szk_section se
where (se.year='1998' or se.year='1999') and
i.instructor_id=se.instructor_id);
Q.9 Retrieve the name of student, department in which student not have grade A in their
subject.
select s.name, s.branch, g.grade from szk_student s, szk_grade_report g
where not g.grade='A' and s.roll_no=g.roll_no
order by g.grade;