Professional Documents
Culture Documents
PRACTICAL FILE
Submitted in partial fulfillment for the award of
BACHELOR OF TECHNOLOGY
(CSE), 3rd year
Submitted by
RUPESH VARSHNEY
Roll No:- 2001090100045
Submitted To
Mr. Kapil Arora
(Database Management Systems Lab: KCS-551)
[Session: 2022-2023]
INDEX
S.NO EXPERIMENTS SIGNATURE
Semester:- 5th
emp_name VARCHAR(30),
designation char(10),
doj date,
salary NUMERIC(9,2),
address VARCHAR(30),
dept_name CHAR(30)
);
VALUES('1001','amit','officer','21-dec-1995','1000','mathura','marketing'),
('1002','sumit','clerk','14-may-1982','500','delhi','accounts'),
('1003','raj','manager','23-dec-1984','3500','bombay','sales'),
('1004','james','analyst','22-jul-1990','5000','mathura','software'),
('1005','amit','analyst','22-jul-1990','4900','delhi','production'),
('1006','jones','clerk','16-apr-1986','950','delhi','production');
SQL QUERIES:
1. List the Emp name, doj from employee table.
3. List the name of emp who belong to Mathura and depart name is Marketing.
5. List the name of the emp who are getting their salary between 800 and 2500.
SELECT emp_name FROM eemployee WHERE salary BETWEEN 800 AND 2500;
7. List the employees who are earning more than 1200 but less than 4000.
15. Find out how many employees are working in the sales department.
emp_name VARCHAR2(20),
designation CHAR(10),
doj DATE,
salary NUMBER(10),
dept_no NUMBER(10)
);
dept_no NUMBER(10),
dept_name CHAR(30),
dept_loc CHAR(30)
);
designation CHAR(10),
sp_allowance NUMBER(9),
conveyance NUMBER(9)
);
VALUES('1001','ROBERT','OFFICER','21-DEC-85','1000','10'),
('1002','ALLAN','CLERK','15-MAY-82','500','10'),
('1003','MARTIN','MANAGER','23-DEC-84','3500','20'),
('1004','JAMES','ANALYST','22-JUL-90','5000','30'),
('1005','JOHN','ANALYST','22-JUN-90','4900','30');
VALUES('10','marketing','london'),
('20','accounts','america'),
('30','sales',' newyork'),
('40','software','boston'),
('50','production','boston');
VALUES('manager','1000','500'),
('officer','800','400'),
('analyst','1200','500'),
('clerk','500','300');
2. List the employee who are earning more than 1200 but less than 4000.
3. List the employee who have joined after 1-Jan-84 in order of joining date.
select * from employee where dept_no=(select dept_no from department where dept_loc=' newyork');
select * from employee where salary > (select salary from employee where emp_name='ROBERT');
11. Find out how many employee are working in Sales department.
select * from employee where dept_no=(select dept_no from department where dept_name='sales');
DESIGNATION GRADE
Manager A
Officer B
Analyst C
Clerk D
15. Display the employees names and doj,joining date should be displayed in the following format:26 JAN,NINTEEN
NINETY-EIGHT.
Select emp_name,
convert(varchar(3),DATEDIFF(MONTH,DOJ,GETDATE())/12)+'years'"YEARS",
convert(varchar(2),DATEDIFF(MONTH,DOJ,GETDATE())%12)+'month'"MONTHS",
convert(int,DATEDIFF(MONTH,DOJ,GETDATE())*30.5)"DATE"
from employee;
3. Display the maximum salaries in each department along with the name of department. The column
heading should be like this: Dept_Name Max(Sum) Hint : Use both the tables – Employee &
Department.
4. Display the total salary( Salary+Sp_allowance_Conveyance) of each employee in the order of total
salary.
5. List the no. of Employees along with their department numbers in each department.
8. List the total salary, maximum and minimum along with the average salary of each employee
designation wise.
9. List the total salary, maximum and minimum along with the average salary of each employee
designation wise for department no.30.
11. List the total salary of the employees for each designation department wise.
12. List the employee details such as his Employee no., Name, Date of Joining, Basic Salary and
Designation of department=’Marketing’.
select emp_no,emp_name,doj,salary,designation from employee where dept_no in (select dept_no from
department where dept_name='marketing');
13. List the employee details such as his Employee no., Name, Date of Joining, Basic Salary and
Designation for the employee working in location = ‘AMERICA’.
select * from department where dept_no not in (select dept_no from employee);
PRACTICAL ASSIGNMENT-4
NAME VARCHAR2(8),
DOB DATE,
DOJ DATE,
SEX VARCHAR2(1),
PROF1 VARCHAR2(8),
PROF2 VARCHAR2(8),
SALARY NUMBER(8)
);
('ALTAF','02-JUL-1980','13-NOV-2001','M','CLIPPER','COBOL',2800),
('JAGDESH','05-OCT-1987','04-OCT-1999','M','ORACLE','JAVA',4100),
('JULIANA','31-JAN-1986','21-APR-1998','F','COBOL','DBASE',3000),
('KAMALA','30-OCT-1992','02-JUN-1999','F','C','DBASE',2900),
('MARY','24-JUN-1989','01-FEB-2004','F','C','ORACLE',4500),
('NELSON','11-SEP-1990','11-OCT-2003','M','COBOL','DBASE',2500),
('PATRICI','16-NOV-1991','21-APR-2002','M','PASCAL','CLIPPER',2800),
('QADIR','31-AUG-1987','21-APR-2006','M','ASSEMBLY','C',3000),
('RAMESH','03-MAY-1983','28-FEB-2005','M','PASCAL','DBASE',3200),
('REBECCA','01-JAN-1987','01-DEC-1990','F','BASIC','COBOL',2500),
('REMITHA','19-APR-1988','20-APR-1993','F','C','ASSEMBLY',3600),
('REVATHI','02-DEC-1991','02-JAN-1992','F','PASCAL','BASIC',3700),
('VIJAYA','11-DEC-1992','02-MAY-1992','F','FOXPRO','C',3500);
NAME VARCHAR2(8),
TITLE VARCHAR2(20),
DEV_IN VARCHAR2(8),
SCOST NUMBER(7,2),
DCOST NUMBER(5),
SOLD NUMBER(3));
INSERT INTO SOFTWARE
VALUES('ANAND','PARACHUTES','BASIC',399.95,6000,43),
('JAGADESH','SHARES MANAGEMENT','ORACLE',3000.00,12000,14),
('JULIANA','INVENTORY CONTROL','COBOL',3000.00,3500,0),
('KAMAL','PAYROLL PACKAGE','DBASE',9000.00,20000,7),
('MARY','CODE GENERATOR','C',4500.00,20000,23),
('MARY','READ ME','C',300.00,1200,84),
('PATRICK','GRAPHIC EDITOR','PASCAL',750.00,5000,11),
('QADIR','BOMBS AWAY','ASSEMBLY',499.80,530,114),
('QADIR','VACCINES','C',1900.00,3400,21),
('RAMESH','HOTEL MANAGEMENT','DBASE',12000.00,35000,4),
('RAMESH','DEAD LEE','PASCAL',99.95,4500,73),
('REMITHA','PC UTILITIES','C',725.00,500,51),
('REVATHI','HOTEL MANAGEMENT','PASCAL',1100.00,75000,2),
('REVATHI','QUIZ MASSTER','BASIC',3200.00,2100,15),
('VIJAYA','ISK EDITOR','C',900.00,700,6);
NAME VARCHAR2(8),
SPLACE VARCHAR2(9),
COURSE VARCHAR2(5),
CCOST NUMBER(5)
);
VALUES('ANAND','SABHARI','PGDCA',4500),
('ALTAF','CCIT','DCA',7200),
('JAGADESH','SSIL','DCA',3500),
('JULIANA','BITS','DCA',22000),
('KAMALA','PRAGATHI','DCP',5000),
('MARY','SABHARI','PGDCA',4500),
('NELSON','PRAGATHI','DAP',5200),
('PATRICK','PRAGATHI','DCAP',5200),
('QADIR','APPLE','HDCP',14000),
('RAMESH','SABHARI','PGDCA',4500),
('REBECCA','BRILLANT','DCA',11000),
('REMITHA','BDPS','DCA',6000),
('REVATHI','SABHARI','DAP',5000),
('VIJAYA','BDPS','DCA',48000);
SELECT NAME FROM PROGRAMMER WHERE SALARY BETWEEN 2000 AND 4000;
9. Display the institute names from the STUDIES table without duplicates.
10. Display the name of the programmers who’s name starts with ‘A’ and the third character is T.
5. Display the names & date of birth of all programmers born in April.
10. Find out the number of copies which should be sold in order to recover the development cost of
each package.
15. How many programmers paid 10000 to 15000 for the course?
SELECT COUNT(*) FROM STUDIES WHERE CCOST BETWEEN 10000 AND 15000;
21. Who are the programmers who celebrate their birthdays during the current month?
24. Display the details of those who don’t know C, C++ or Pascal.
SELECT * FROM PROGRAMMER WHERE PROF1 NOT IN ('C','C++','PASCAL') AND PROF2 NOT IN
('C','C++','PASCAL');
25. Display the costliest package developed by each programmer.
26. Produce the following output for all the male programmers
( Programmer
SELECT 'Mr.' || NAME || ' - has ' || TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12) || ' years of experience'
“Programmer” FROM PROGRAMMER WHERE SEX = 'M' UNION SELECT 'Ms.' || NAME || ' - has ' || TRUNC
(MONTHS_BETWEEN (SYSDATE,DOJ)/12) || ' years of experience' “Programmer”