248154_Onkar Khade Database Technologies Lab Assignments
248154_Onkar Khade Database Technologies Lab Assignments
Rollno : 248154
Practical Batch : B
8.To list all the record with sal not equal to 1250 or 1100 or 2850
Code and Output :
9. To list all employees with sal not >1250 and <2850
Code and Output :
10. To list all employees with job starts with C , E at 3rd position and ends with
K
Code and Output :
14. To list all employees with name contain ‘A’ at 1 position and job Contains 5
characters
Code and Output :
Q2. Solve the following
1. Retrieve the details (Name, Salary and dept no) of the emp who are working
in department code 20, 30 and 40.
Code and Output :
2. Display the total salary of all employees . Total salary will be calculated as
sal+comm+sal*0.10
Code and Output :
3. List the Name and job of the emp who have joined before 1 jan 1986 and
whose salary range is between 1200and 2500. Display the columns with user
defined Column headers.
Code and Output :
4. List the empno, name, and department number of the emp works under
manager with id 7698
Code and Output :
5. List the name, job, and salary of the emp who are working in
departments 10 and 30.
Code and Output :
6. List the name, job, and salary of the emp who are working in departments
10 and Display name concatenated with dept code separated by comma and
space. Name the column as ‘Emp info’.
Code and Output :
8. Write a query which will display name, department no and date of joining of
all employee who were joined January 1, 1981 and March 31, 1983. Sort it
based on date of joining (ascending).
Code and Output :
9. Display the employee details where the job contains word ‘AGE’ anywhere in
the Job
Code and Output :
10. List the details of the employee , whose names start with ‘A’ and end with
‘S’ or whose names contains N as the second or third character, and ending
with either ‘N’ or ‘S’.
Code and Output :
11. List the names of the emp having ‘_’ character in their name.
Code and Output :
Group functions
1. Display the Highest, Lowest, Total & Average salary of all employee. Label the
columns Maximum, Minimum, Total and Average respectively for each
Department. Also round the result to the nearest whole number.
Code and Output :
3 Get the Department number, and sum of Salary of all non managers where
the sum is greater than 20000.
Code and Output :
Day 2 Assignment
Write SQL statement for the following
1. To find all managers with salary >1500
Code and Output:
5. List all employees with name starts with A and ends with N
Code and Output:
4. list all employees with salary either equal to 3000 or 1250 or 2500
Code and Output :
5. list all employee with name=SMITH
Code and Output :
9. list all employees with name starts with A ends with N and somewhere in
between L is there
Code and Output :
10. list all employees with name starts with A and B at 3 rd position and P at
second last position
Code and Output :
11. List all employees with name starts with either A or starts with S or
starts with W
Code and Output :
12. find max sal and min sal for each job
Code and Output :
15. find maximum salary,average sal for each job in every department
Code and Output :
16. find max salary for every department if deptno is > 15 and arrange data
in deptno order.
Code and Output :
17. find sum salary for every department if sum is > 3000
Code and Output :
19. count how many employees earn salary more than 2000 in each job
Code and Output :
22. display min sal,max sal, average sal for all employees working under
same manager
Code and Output :
23. find sum of total earnings(sal+comm), average of sal+comm for all
employees who earn sal > 2000 and work in either dept no 10 or 20
Code and Output :
24. list all employees who joined in Aug 1980 and salary is >1500 and <
2500
Code and Output :
27. list empcode,empno,name and job for each employee. (note :empcode
is 3 to 5 characters from name and last 2 characters of job)
Code and Output :
30. Display empid, name, deptno and department name by using following
conditions. dept 10 then "Hr" if 20 then "Admin" if 30 then "accounts"
otherwise purchase
Code and Output :
Topic ----------------- create Table, DML , subquery and joins
31. Practice creating following tables
create table mydept_DBDA ( deptid number primary key, dname
varchar2(20) not null unique, dloc varchar2(20) )
insert into mydept_DBDA values(30,'Purchase','Mumbai');
Code and Output :
create table myemployee ( empno number(5) primary key, fname
varchar2(15) not null, mname varchar2(15), lname varchar2(15) not null, sal
number(9,2) check(sal >=1000), doj date default sysdate, passportnum
varchar2(15) unique, deptno number constraint fk_deptno references
mydept_DBDA(deptid) on delete cascade )
Code and Output :
dept---→ deptno
salgrade---→ grade
add new column in emp table netsal with constraint default 1000
35. Update employee sal ---- increase sal of each employee by 15 % sal +comm,
change the job to manager and mgr to 7777 for all employees in deptno 10.
36. change job of smith to senior clerk
37. increase salary of all employees by 15% if they are earning some
commission
40. list all employees with sal < rajan's sal and salary > revati's sal
43. change salary of all emplees who working in Wall's department to the
salary of Miller.
44. list all employees with salary > either Smith's salary or alan's sal
45. list all employees who earn more than average sal of dept 10
46. list all employees who earn more than average sal of Alan's department
48. list all employees who earn more than average salary of their own
department
49. list all employees who earn sal < than their managers salary
50. list all employees who are earning more than average salary of their job
2. list all product name and salesman name for all salesman who stays in pune
55. create following tables and solve following questions(primary keys are
marked in yellow) foreign keys are marked in green
faculty(fid,fname,sp.skill1,sp.skill2) courses(cid,cname,rid,fid)
room(roomid,rname,rloc)
Room
roomid rname rloc
100 jasmin 1st floor
101 Rose 2nd floor
105 Lotus 1st floor
103 Mogra 1st floor
1. list all courses for which no room is assigned and all rooms for which are
available
2. list all faculties who are not allocated to any course and rooms which are not
allocated to any course
3. list all rooms which are allocated or not allocated to any courses
5. display courses and faculty assigned to those courses whose special skill is
database
6. display time table --- it should contain course details , faculty and room
details
56. create following tables with given constraints product---- qty >0, default
20.00,pname not null and unique
1. List all products with category chips
6. list all salesman who stays in city with name starts with P or N
4. find all customer name,vehicle name,salesman name for all salesman who
stays in pune
7. find all customer name, vehicle name, salesman name, discount earn by all
customer
check what all records will appear in employee table rollback upto A
check what all records will appear in employee table
commit all changes
check what all records will appear in employee table check whether you can
roll back the contents.
14. create a procedure getMin(deptno,minsal) to find minimum salary of given
table.
PLSQL ASSIGNMENT
Solve the following Loops example
1. Print the following patterns using loop :
a.
*
**
***
****
b.
*
***
*****
***
*
c.
1010101
10101
101
1
d.
1
12
123
1234
12345
1.
2. write a procedure to insert record into employee table. the procedure
should accept empno, ename, sal, job, hiredate as input parameter write insert
statement inside procedure insert_rec to add one record into table
create procedure insert_rec(peno int,pnm varchar(20),psal decimal(9,2),pjob
varchar(20),phiredate date) begin insert into
emp(empno,ename,sal,job,hiredate) values(peno,pnm,psal,pjob,phiredate)
end//
3. write a procedure to delete record from employee table. the procedure
should accept empno as input parameter. write delete statement inside
procedure delete_emp to delete one record from emp table
4. write a procedure to display empno,ename,deptno,dname for all employees
with sal > given salary. pass salary as a parameter to procedure
5. write a procedure to find min,max,avg of salary and number of employees in
the given deptno. deptno --→ in parameter min,max,avg and count ---→ out
type parameter execute procedure and then display values min,max,avg and
count
1.All Employee’s with the desg as ‘CLERK’ are now called as (AO) Administrative
Officers. Update the Employee collection for this.
2. Change the number of hours for project-1 to 5 for all employees with
designation analyst.
3. Add 2 projects project-3 and project-4 for employee whose name starts with
”Deep” with 2 hrs
db.emp.update({name:/^Deep/},{$push:{project:{$each:[{name:'project
3',Hrs:2},{name:'project-4',Hrs:2}]}}}, {multi:true})
4. Add bonus rs 2000 for all employees with salary > 50000
5. add bonus 1500 if salary 30000
10. Delete project-2 from all employee document if they are working on the
project for 4 hrs. db.emp.update({},{$pull:{“project.name”:”project-
2”,”project.Hrs”:4}},{multi:true}) or
db.Emp.update({},{$pull:{project:{name:'project-2',Hrs:4}}},{multi:true}) or
db.emp.update({},{$pull:{“project:{$elemMatch:{name:”project-
2”,”Hrs”:4}},{multi:true})
11. Change the salary of employees to 10000 only if their salary is < 10000
12. Increase bonus of all employees by 500 if the bonus is < 20000 or if
employee belong to sales department
13. Add 2 new project at position 2 for all employees with designation analyst
or salary is equal to either 30000 or 33000 or 35000
14. Delete last project of all employees with department name is “HR” and if
the location is Mumbai
17. Add list of skillset in all employee documents who are working on project-4
for 3 hrs or on project-3 for 4 hrs
18. Add a new hobby as blogging at 3 position in hobbies array for all
employess whose name starts with R or p and ends with j or s
19. Increase salary by 10000 for all employees who are working on project-2 or
project-3 or project-1
20. Decrease bonus by 1000 rs And increase salary by 1000rs for all employees
whose department location is Mumbai
21. Remove all employees working on project-4
23. Change skill python to python 3.8 for all employees if python is there in the
skillset
24. Add 2 skills MongoDb and Perl at the end of skillset array for all employees
who are working at Pune location
25. Delete first hobby from hobby array for all employees who are working on
project-1 or project-2
26. Delete last hobby from hobbies array for all employees who are working on
project which is at 2 nd position in projects array for 4 hrs
27. Add 2 new projects at the end of array for all employees whose skillset
contains Perl or python
28. Change hrs to 6 for project-1 for all employees if they working on the
project-1 for < 6 hrs. otherwise keep the existing value.
MONGO DBASSIGNMENT 2
1. Write a MongoDB query to display all the documents in the collection
restaurants
2. Write a MongoDB query to display the fields restaurant_id, name, borough
and cuisine for all the documents in the collection restaurant.
3. Write a MongoDB query to display the fields restaurant_id, name, borough
and cuisine, but exclude the field _id for all the documents in the collection
restaurant.
4. Write a MongoDB query to display the fields restaurant_id, name, borough
and zip code, but exclude the field _id for all the documents in the collection
restaurant.
5. Write a MongoDB query to display all the restaurant which is in the borough
Bronx
6. Write a MongoDB query to display the first 5 restaurant which is in the
borough Bronx.
7.Write a MongoDB query to display the next 5 restaurants after skipping first 5
which are in the borough Bronx.
8. Write a MongoDB query to find the restaurants who achieved a score more
than 90.
9. Write a MongoDB query to find the restaurants that achieved a score, more
than 80 but less than 100.
10. Write a MongoDB query to find the restaurants which locate in latitude
value less than 95.754168.
11. Write a MongoDB query to find the restaurants that do not prepare any
cuisine of 'American' and their grade score more than 70 and latitude less than
-65.754168.
12. Write a MongoDB query to find the restaurants which do not prepare any
cuisine of 'American' and achieved a score more than 70 and located in the
longitude less than 65.754168.
13. Write a MongoDB query to find the restaurants which do not prepare any
cuisine of 'American ' and achieved a grade point 'A' not belongs to the
borough Brooklyn. The document must be displayed according to the cuisine in
descending order.
14. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which contain 'Wil' as first three letters for its
name.
15. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which contain 'ces' as last three letters for its
name.
16. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which contain 'Reg' as three letters somewhere in
its name.
17. Write a MongoDB query to find the restaurants which belong to the
borough Bronx and prepared either American or Chinese dish.
18. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which belong to the borough Staten Island or
Queens or Bronxor Brooklyn.
19. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which are not belonging to the borough Staten
Island or Queens or Bronxor Brooklyn.
20. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which achieved a score which is not more than 10.
21. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which prepared dish except 'American' and
'Chinees' or restaurant's name begins with letter 'Wil'.
22. Write a MongoDB query to find the restaurant Id, name, and grades for
those restaurants which achieved a grade of "A" and scored 11 on an ISODate
"2014-08-11T00:00:00Z" among many of survey dates
23. Write a MongoDB query to find the restaurant Id, name and grades for
those restaurants where the 2nd element of grades array contains a grade of
"A" and score 9 on an ISODate "2014-08-11T00:00:00Z".
24. Write a MongoDB query to find the restaurant Id, name, address and
geographical location for those restaurants where 2nd element of coord array
contains a value which is more than 42 and upto 52
25. Write a MongoDB query to arrange the name of the restaurants in
ascending order along with all the columns.
26. Write a MongoDB query to arrange the name of the restaurants in
descending along with all the columns.
27. Write a MongoDB query to arranged the name of the cuisine in ascending
order and for that same cuisine borough should be in descending order.
28. Write a MongoDB query to know whether all the addresses contains the
street or not.
29. Write a MongoDB query which will select all documents in the restaurants
collection where the coord field value is Double.
30. Write a MongoDB query which will select the restaurant Id, name and
grades for those restaurants which returns 0 as a remainder after dividing the
score by 7.
31. Write a MongoDB query to find the restaurant name, borough, longitude
and attitude and cuisine for those restaurants which contains 'mon' as three
letters somewhere in its name.
32. Write a MongoDB query to find the restaurant name, borough, longitude
and latitude and cuisine for those restaurants which contain 'Mad' as first three
letters of its name.