1. For college database execute following queries: Department ( dept _Id ,dept_name , budget) Teacher( Teacher_id , name, salary, dept_id) Course ( course_id title, credits, dept_id) Teaches ( course_id, Teacher_id ) Find the names of all teachers in Computer dept who have salary greater than 70000. Find the names of teachers who are working in IT dept. Create a view to find out name and salary of teacher. Find the names of all teachers whose salary is greater than at least one teacher in Mechanical dept. Create Database College ; use College ; create table dept(dept_id int,dept_name varchar(30),budget int); create table teacher(teacher_id int, name varchar(10), salary int, dept_id int); create table course(course_id int, title varchar(30),credits int, dept_id int); create table teaches(course_id int, teacher_id int); insert into dept values(101,"MECH","70000"); insert into dept values(102,"IT","75000"); insert into dept values(102,"COMP","80000"); select * from dept; insert into teacher values(1,"Rakesh",80000,101); insert into teacher values(2,"Ram",20000,102); insert into teacher values(3,"Rajesh",72000,103); insert into teacher values(4,"Rohit",100000,102); insert into teacher values(5,"Arjun",85000,103); select * from teacher; insert into course values(901,"AI",10,101); insert into course values(902,"ML",20,102); insert into course values(903,"IOT",30,103); select * from course; insert into teaches values(901,1); insert into teaches values(902,2); insert into teaches values(903,3); insert into teaches values(902,4); select * from teaches; select name from teacher where dept_id in(select dept_id from dept where dept_name = "COMP" )and salary >70000; select name from teacher where dept_id in (select dept_id from dept where dept_name = 'IT'); select name from teacher where salary > ( select salary from teacher where dept_id = 101); 2. For Employee database execute following queries: Department ( dept_name , building, budget) Employee( Emp_id , name, salary, dept_name) Project( proj_id , title, dept_name) Workson ( emp_id, proj_id ) Create a view to find employee name and project title for employee in IT department. Find the names of all departments whose name includes substring “ p”. List the entire employee records in descending order. Find the names of all employees whose salary is greater than at least one employee in production dept. create database Employee; use Employee; create table Department(dept_name varchar(30) , building varchar(10) , budget int ); insert into Department values("IT","A" , 100000 ); insert into Department values("COMP","B" , 90000); insert into Department values("ENTC","C" , 80000 ); insert into Department values("Production","D" , 70000); select * from Department ; create table emp(Emp_id int , E_name varchar(20) , salary int , dept_name varchar (30) ) ; insert into emp values(1 , "Sahil" , 35000 , "COMP"); insert into emp values(2 , "Shantanu" , 50000 , "IT" ); insert into emp values(3 , "Pratik" , 30000 , "IT" ); insert into emp values(4 , "Prasad" , 20000 , "COMP" ); insert into emp values(5 , "Anvit" , 35000 , "COMP"); insert into emp values(6 , “Adesh" , 40000 , "ENTC" ); insert into emp values(7 , "Shreeraj” , 25000 , "ENTC"); insert into emp values(8 , “Yash" , 15000 , " Production"); alter table emp add (dept_id int) ; select * from emp ; create table project(proj_id int , p_title varchar(20) , dept_name varchar(30) ) ; insert into project values(4545 , "AI" , "IT"); insert into project values(5757 , "ML" , "COMP"); insert into project values(3434 , "IOT" , "ENTC"); select * from project ; create table works_on (Emp_id , proj_id) insert into works_on values(1 , 4545); insert into works_on values(2 , 5757); insert into works_on values(3 , 3434); Select * from Department where dept_name like "%p%"; select * from emp order by Emp_id DESC ; select E_name from emp where salary > ( select salary from emp where dept_name = "Production"); 3. For University database execute following queries: Department ( dept_name , building, budget) Instructor ( inst_id , name, salary, dept_name) Course ( course_id , title, credits, dept_name) Teaches ( course_id, inst_id ) Find the average salary of the instructors who are in music dept. Find the average salary in each dept. Find out department name with average salary in each department where average salary is greater than 40000. Find the names of all instructors whose salary is greater than at least one instructor in biology dept. create database university; use university; create table department(dept_name varchar(30), building varchar(20), budget int(30), primary key(dept_name)); desc department; create table instructor( inst_id int(20), salary int(30), primary key(inst_id), dept_name varchar(20), foreign key(dept_name)references department(dept_name) ); desc instructor; create table course( course_id int(20), title varchar(30), credit int(5), primary key(course_id), dept_name varchar(20), foreign key(dept_name) references department(dept_name) ); desc course; CREATE TABLE teaches( course_id varchar(30), inst_id varchar(20) ); desc teaches; INSERT INTO department(dept_name, building, budget) values ("IT", "A", 25000), ("ML", "B", 30000), ("CSBS", "C", 35000), ("Cloud", "D", 40000); (“Biology” , “E” , 50000); select *from department; INSERT INTO instructor(inst_id, salary, dept_name) values (1, 20000, "IT"), (2, 15000, "ML"), (3, 25000, "CSBS"), (4, 30000, "Cloud"); (5, 50000 , “Biology”); select *from instructor; INSERT INTO course(course_id, title, credit, dept_name) values (5, "abc", 2, "IT"), (6, "efg", 3, "ML"), (7, "ijk", 4, "CSBS"), (8, "mno", 5, "Cloud"); select *from course; INSERT into teaches(course_id, inst_id) values (5, 1), (6, 2), (7, 3), (8, 4); select *from teaches; select avg(salary) from instructor; select avg(salary) from instructor group by dept_name; select dept_name from instructor where salary > (select salary from instructor where inst_id = 5); 4. For student database execute following queries: Find the record of the students who has got the highest marks in DBMS subject using successive queries. Find the average result of TOC subject. Find the minimum marks in CNT subject. Find the total number of students who scored first class. create database student; use student; create table marks ( sid int,name varchar(30),dbms int,cnt int ,toc int,grade varchar(2)); insert into marks values (1,"Shantanu",145,120,95,'A'), (2,"Shreeraj",150,120,100,'C'), (3,"Sahil",15,10,5,'B'), (4,"Pratik",0,0,0,'F'); select *from marks; select *from marks where dbms=(select max(dbms) from marks); select avg(toc) as average_toc from marks; select min(cnt) as min_cnt from marks; select *from marks where grade='A'; 5. For banking database execute following queries: Branch( branch_name , building, asset) Customer( cust_id , name,address,account_type) Account( acc_number ,balance,branch_name) Depositor( acc_number, cust_id) Loan(Loan_no,amount) Borrower(Loan_no , cust_id) Find the number of all accounts who have branch_name as pune. Find the names of all customer who have saving account in bank. Create a view to find all customers who have account and loan in the bank Show the branch name and number of account in that branch create database Banking ; use Banking ; create table branch (branch_name varchar (15),building varchar (20),asset int (10), primary key (branch_name)); create table customer ( customer_id int (10), customer_name varchar (30), address varchar (40), account_type varchar(20) , primary key (customer_id)); create table account ( account_no int (10), balance int (10), branch_name varchar (20), foreign key (branch_name) references branch(branch_name), primary key (account_no)); create table depositer (account_no int (10), foreign key (account_no) references account(account_no), customer_id int (10)); create table loan( loan_no int (10), amount int (10)); create table borrower(loan_no int (10), customer_id int (10) ); insert into branch values ('Pune','A',200); insert into branch values ('Tathawade','B',400); insert into branch values ('Akurdi','C',500); insert into branch values ('Shivajinagar','D',300); insert into branch values ('Solapur','E',600); select *from branch; select count(account_no) from account, branch group by branch_nameprodsp_update_Counterprod; insert into customer values (10,'Anvit','Pune' , 'saving'); insert into customer values (20,'Shantanu','Tathawade', 'current'); insert into customer values (30,'Pratik','Akurdi', 'saving'); insert into customer values (40,'Omkar','Solapur' , 'current'); select *from customer; insert into account values (100,2000000,'Pune'); insert into account values (200,3000000,'Tathawade'); insert into account values (300,4000000,'Akurdi'); insert into account values (400,5000000,'Solapur'); select *from account; insert into depositer values (100,10); insert into depositer values (200,20); insert into depositer values (300,30); insert into depositer values (400,40); select *from depositer; insert into loan values (25,20000); insert into loan values (26,30000); insert into loan values (27,40000); insert into loan values (28,50000); select *from loan; insert into borrower values (25,10); insert into borrower values (26,20); insert into borrower values (27,30); insert into borrower values (28,40); select *from borrower; select * from account where branch_name = 'Pune' ; create view loans as select distinct customer_id,T.loan_no from borrower as T,loan as S where T.loan_no=S.loan_no; select customer_name from customer where account_type = 'saving' ; select count(account_no) , branch_name from account group by branch_name 6. Create college database (using mongodb) Find the list of teachers in IT dept. Find the list of teachers who have salary greater than 40000. Find the teacher’s list in descending order using teacher id. Give the increment of rs.20000 who has salary less than 30000. db.college.insertMany([{id:1, name:"utkarsh", occupation:"teacher", salary:20000},{id:2, name:"shantanu", occupation:"student", salary:0},{id:3, name:"Yash", occupation:"teacher", salary:50000},{id:4, name:"prasad", occupation:"student", salary:0},{id:5, name:"Shriram", occupation:"teacher", salary:55000}]) 1. List of teachers in db.college.find({occupation: "teacher"}) 2. Salary greater than 40000 db.college.find({salary: {$gt:40000}}).pretty() 3. Teachers id in descending order db.college.find().sort({id:-1}) 7. Create library database (using mongodb) List the books of computer subjects. List the books whose publication is “Pearson” List the number of journals. List the number of books which price is less than rs.500. db.library.insertMany([{id:1, bookname:"the secret", publication:"Pearson", fiction:"novel", price:200},{id:2, bookname:"Architecture", publication:"Pearson", fiction:"journal", price:300},{id:3, bookname:"business", publication:"Pearson", fiction:"journal", price:400},{id:4, bookname:"c++", publication:"Balaji", fiction:"computer subject", price:600},{id:5, bookname:"python", publication:"Balaji", fiction:"computer subject", price:700}]) 1. List of computer subject in db.library.find({fiction: "computer subject"}) 2. List the books whose publication is “Pearson” db.library.find({publication: "Pearson"}) List of number of journals db.library.find({fiction: “journal”}).count() No of books which price is less than 500 db.library.find({price: {$lt:500}}).pretty() 8. Create the collection SALE as follows using MongoDB id items price Quantity 1) Compute the total of each item number. 1 Shirt 100 2 2) Find all details of items from the sale collection. 2 Pant 200 1 3) Compute the average quantity for each item. 3 Sari 500 5 4) Compute the maximum quantity for each item. 4 Shirt 100 10 5) Compute the minimum quantity for each item. 5 Sari 500 10 6) Compute the total of each item number. > use sales switched to db sales > db.createCollection("SALE") { "ok" : 1 } > > db.SALE.insert([{_id:1, Items: "Shirt",Price: 100, Quantity: 2}, {_id:2, Items: "Pant",Price: 200, Quantity:1}, {_id:3, Items: "Sari",Price: 500, Quantity:5}, {_id:4, Items: "Shirt",Price: 100, Quantity:10}, {_id:5, Items: "Sari",Price: 500, Quantity:10}]) BulkWriteResult({ "writeErrors" : [ ], "writeConcernErrors" : [ ], "nInserted" : 5, "nUpserted" : 0, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "upserted" : [ ] }) > db.SALE.update({_id:1}, {$set:{"Total":Price*Quantity}}) uncaught exception: ReferenceError: Price is not defined : @(shell):1:32 > db.SALE.update({_id:1}, {$set:{"Total":"Price"*"Quantity"}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) uncaught exception: TypeError: bulkResult.upserted is undefined : WriteResult@src/mongo/shell/bulk_api.js:117:1 WriteResult@src/mongo/shell/bulk_api.js:108:20 @(shell):1:1 > db.SALE.find().pretty() { "_id" : 1, "Items" : "Shirt", "Price" : 100, "Quantity" : 2, "Total" : NaN } { "_id" : 2, "Items" : "Pant", "Price" : 200, "Quantity" : 1 } { "_id" : 3, "Items" : "Sari", "Price" : 500, "Quantity" : 5 } { "_id" : 4, "Items" : "Shirt", "Price" : 100, "Quantity" : 10 } { "_id" : 5, "Items" : "Sari", "Price" : 500, "Quantity" : 10 } > db.SALE.update({_id:1}, {$set:{"Total":"Price*Quantity"}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.SALE.find().pretty() { "_id" : 1, "Items" : "Shirt", "Price" : 100, "Quantity" : 2, "Total" : "Price*Quantity" } { "_id" : 2, "Items" : "Pant", "Price" : 200, "Quantity" : 1 } { "_id" : 3, "Items" : "Sari", "Price" : 500, "Quantity" : 5 } { "_id" : 4, "Items" : "Shirt", "Price" : 100, "Quantity" : 10 } { "_id" : 5, "Items" : "Sari", "Price" : 500, "Quantity" : 10 } > 9. Create cursor to update the table and increase salary of each customer by 500 10. Create trigger to deduct the quantity after selling the item create database query_10; use query_10; create table sale1(item_id int, product_name varchar(20),total_quantity int, quantity_sold int); insert into sale1 values(101, "Oreo", 294, 24); insert into sale1 values(102, "Good_day", 135, 19); insert into sale1 values(103, "Bourborn", 167, 37); insert into sale1 values(104, "Jim-Jam", 242, 71); insert into sale1 values(105, "Parle_G", 322, 20); alter table sale1 add rem_quantity int; select * from sale1; delimiter // create trigger t1 before update on sale1 for each row begin set new.rem_quantity=old.total_quantity-old.quantity_sold; end; // delimiter ; update sale1 set quantity_sold = 28 where item_id = 101; update sale1 set quantity_sold = 11 where item_id = 102; update sale1 set quantity_sold = 73 where item_id = 103; update sale1 set quantity_sold = 66 where item_id = 104; update sale1 set quantity_sold = 19 where item_id = 105; 11. create stored procedure to determine total marks of student and check whether student is pass or fail students (roll , CT , DBMS , CN Total , criteria ) #create stored procedure to determine total marks of student and check whether student is pass or fail create database student_marks1111; use student_marks1111; create table student5 (roll int , CT int, DBMS int, CN int, Total int, criteria varchar(20)); delimiter $$ Create procedure sp_result12345 ( IN roll1 int,CT int, DBMS int, CN int ,OUT Total int, out criteria varchar(20) ) Begin Insert into student5(roll,ct, dbms,cn) values (roll1,ct, dbms, cn); Update student5 set total= ct +dbms+ cn where roll=roll1; set total= ct +dbms+ cn; Update student5 set criteria= "pass" where total >=200 and roll=roll1; Update student5 set criteria= "Fail" where total <200 and roll=roll1; End ; $$ delimiter ; call sp_result12345(1,60,60,60, @total, @criteria); call sp_result12345(2,90,50,80, @total, @criteria); call sp_result12345(3,50,50,50, @total, @criteria); call sp_result12345(4,80,70,60, @total, @criteria); call sp_result12345(5,100,95,90, @total, @criteria); select * from student5; 12. create trigger to set the age as zero if age entered is negative table customer(cust_id,age name ); #create trigger to set the age as zero if age entered is negative # table customer(cust_id,age name ); create database trigger_pr1; use trigger_pr1; # before insert trigger create table customer(cust_id int,age int,name varchar(30)); delimiter // create trigger age_verify before insert on customer for each row if new.age <0 then set new.age=0; end if; // insert into customer values(101,27,"james"),(102,-32,"sahil"),(103,19,"nikhil"),(104,21,"shantanu"); select *from customer; 13. Create a collection Teacher_info using MongoDB as follows Teacher_id Teacher_Name Dept_Name Salary Status Pic001 Ravi IT 30000 A Pic002 Mangesh IT 20000 A Pic003 Akshay Comp 25500 N Pic004 Rakesh Mech 35000 N Pic005 Ramesh Civil 25000 A List all teachers whose status is “A” in descending order. Delete the teacher info whose Teacher_id is “Pic001”. Change the name of Teacher” Ravi” with “Ravi Kumar”. Increase salary of all teachers which status is “A” with 10000. Count the number of IT department. > use Teacher_info switched to db Teacher_info > db.Teacher_info.find().pretty() { "_id" : 1, "Tname" : "Ravi", "Dept_name" : "IT", "Salary" : 30000, "Status" : "A" } { "_id" : 2, "Tname" : "Mangesh", "Dept_name" : "IT", "Salary" : 20000, "Status" : "A" } { "_id" : 3, "Tname" : "Akshay", "Dept_name" : "Comp", "Salary" : 25500, "Status" : "N" } { "_id" : 4, "Tname" : "Rakesh", "Dept_name" : "Mech", "Salary" : 35000, "Status" : "N" } { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } 1.List all teachers whose status is “A” in descending order --> > db.Teacher_info.find().sort({Status:-1}) { "_id" : 3, "Tname" : "Akshay", "Dept_name" : "Comp", "Salary" : 25500, " Status" : "N" } { "_id" : 4, "Tname" : "Rakesh", "Dept_name" : "Mech", "Salary" : 35000, "Status" : "N" } { "_id" : 1, "Tname" : "Ravi", "Dept_name" : "IT", "Salary" : 30000, "Status" : "A" } { "_id" : 2, "Tname" : "Mangesh", "Dept_name" : "IT", "Salary" : 20000, "Status" : "A" } { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } 2.Delete the teacher info whose Teacher_id is “Pic001”. -->> > db.Teacher_info.deleteMany({_id:1}) { "acknowledged" : true, "deletedCount" : 1 } 3.Change the name of Teacher” Ravi” with “Ravi Kumar”. --> > db.Teacher_info.update({Tname:"Rakesh"},{$set:{Tname:"Ravi Kumar"}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) 4.Increase salary of all teachers which status is “A” with 10000. --> > db.Teacher_info.update({Status:"A"},{$inc:{Salary:10000}},{multi:true}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) 5.Count the number of IT department --> > db.Teacher_info.find({Dept_name:"IT"}).count() 1 14. Consider the following schema: Suppliers (sid: integer, sname: varchar(50), address: varchar(60)),sid as a primary key. Parts (pid: integer, pname: varchar(50), color: varchar(20)),pid as primary key. Catalog (sid: integer, pid: integer, cost: real),sid and pid as a foreign key which refers Supplier and Parts table respectively. Insert values in each table. Write SQL command for each of the following queries. Find the distinct pnames of all parts. Alter the data types of sname as varchar(30). Find out the supplier who is supplying part “Keyboard” whose cost is 5000. Remove all parts whose name is “Mouse”. List all supplier whose name start with “S” in descending order. create database company; use company; create table suppliers( sid int (5), sname varchar (50), address varchar (60), primary key (sid)); create table parts ( pid int (5), pname varchar (50), colour varchar (20), primary key (pid)); create table catalog( sid int (5), pid int (5), cost real , foreign key (sid) references suppliers(sid), foreign key (pid) references parts(pid) ); show tables; insert into suppliers values (101,'Rohan','Pune'); insert into suppliers values (102,'Shyam','Solapur'); insert into suppliers values (103,'Viraj','Satara'); insert into suppliers values (104,'Shantanu','Akurdi'); insert into suppliers values (105,'Anvit','Pune'); select *from suppliers; insert into parts values (201,'Mouse','Black'); insert into parts values (202,'Printer','White'); insert into parts values (203,'Monitor','Black'); insert into parts values (204,'Keyboard','Blue'); insert into parts values (205,'CPU','Grey'); select *from parts; insert into catalog (sid, pid, cost) values (101,201,3000); insert into catalog (sid, pid, cost) values (102,202,8000); insert into catalog (sid, pid, cost) values (103,203,10000); insert into catalog (sid, pid, cost) values (104,204,5000); insert into catalog (sid, pid, cost) values (105,205,9000); select *from catalog; select distinct pname from parts; #1 SET FOREIGN_KEY_CHECKS=0; delete from parts where pname='mouse'; select *from parts; #4 ALTER TABLE suppliers Modify column sname varchar(30); #2 select sname from suppliers where sname LIKE ('S%'); 15. Create a collection Teacher_info using MongoDB as follows T_id T_Name Dept_Name Salary Status List all teachers whose salary is 25000. 01 Ravi IT 30000 A List all teachers whose status is “A” and salary 20000. 02 Mangesh IT 20000 A List all teachers whose status is “N” or salary 25000. 03 Akshay Comp 25500 N List all teachers whose salary is greater than 20000. 04 Rakesh Mech 35000 N List all teachers whose salary is less than 30000. 05 Ramesh Civil 25000 A List all teachers whose salary is 25000. > use Teacher_info switched to db Teacher_info > db.Teacher_info.insertMany([{_id:01,Tname:"Ravi",Dept_name:"IT",Salary:300 00,Status:"A"}, {_id:02,Tname:"Mangesh",Dept_name:"IT",Salary:20000,Status:"A"}, {_id:03,Tname:"Akshay",Dept_name:"Comp",Salary:25500,Status:"N"}, {_id:04,Tname:"Rakesh",Dept_name:"Mech",Salary:35000,Status:"N"}, {_id:05,Tname:"Ramesh",Dept_name:"Civil",Salary:25000,Status:"A"}]) { "acknowledged" : true, "insertedIds" : [ 1, 2, 3, 4, 5 ] } > db.Teacher_info.find().pretty() { "_id" : 1, "Tname" : "Ravi", "Dept_name" : "IT", "Salary" : 30000, "Status" : "A" } { "_id" : 2, "Tname" : "Mangesh", "Dept_name" : "IT", "Salary" : 20000, "Status" : "A" } { "_id" : 3, "Tname" : "Akshay", "Dept_name" : "Comp", "Salary" : 25500, "Status" : "N" } { "_id" : 4, "Tname" : "Rakesh", "Dept_name" : "Mech", "Salary" : 35000, "Status" : "N" } { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } > db.Teacher_info.find({Salary:25000}) { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } > db.Teacher_info.find({$and: [{Salary:20000},{Status:"A"}]}) { "_id" : 2, "Tname" : "Mangesh", "Dept_name" : "IT", "Salary" : 20000, "Status" : "A" } > db.Teacher_info.find({$or: [{Salary:25000},{Status:"N"}]}) { "_id" : 3, "Tname" : "Akshay", "Dept_name" : "Comp", "Salary" : 25500, "Status" : "N" } { "_id" : 4, "Tname" : "Rakesh", "Dept_name" : "Mech", "Salary" : 35000, "Status" : "N" } { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } > db.Teacher_info.find({Salary:{$gt:25000}}) { "_id" : 1, "Tname" : "Ravi", "Dept_name" : "IT", "Salary" : 30000, "Status" : "A" } { "_id" : 3, "Tname" : "Akshay", "Dept_name" : "Comp", "Salary" : 25500, "Status" : "N" } { "_id" : 4, "Tname" : "Rakesh", "Dept_name" : "Mech", "Salary" : 35000, "Status" : "N" } > db.Teacher_info.find({Salary:{$lt:30000}}) { "_id" : 2, "Tname" : "Mangesh", "Dept_name" : "IT", "Salary" : 20000, "Status" : "A" } { "_id" : 3, "Tname" : "Akshay", "Dept_name" : "Comp", "Salary" : 25500, "Status" : "N" } { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } > db.Teacher_info.find({Salary:25000}) { "_id" : 5, "Tname" : "Ramesh", "Dept_name" : "Civil", "Salary" : 25000, "Status" : "A" } > 16. Create table Employee(Employee_Id,Lastname,Firstname,Middlename,Job_Id,Manager_id,Hiredate,Salary,Department_id) .Insert following records. Employee_Id Lastname Firstname Middlen ame Job_Id Manager _id Hiredate Salar y Departmen t_id 7369 Smith Jon Q 667 7902 17-DEC-84 800 10 7499 Allen Kevin J 670 7698 20-FEB-85 1600 20 7505 Doyle Jean K 671 7839 04-APR-85 2850 20 7506 Dennis Lynn S 671 7839 15-MAY-85 2750 30 7507 Baker Leslie D 671 7839 10-JUN-85 2200 40 7521 wark cynthia D 670 7698 22-FEB-85 1250 10 Create a view for all column of Employee table. Create a view of last name, firstname, middlename of Employee table. Create a view of all employees whose last name start from “S” and middle name is “Q”. Create a view of all employees with salary incremented by 10 %. Delete view for all column of Employee. create database mycompany; use mycompany; create table Employee_details(Employee_id int,Lastname varchar(30),Firstname varchar(30),Middlename varchar(30),Job_id int,manager_id int,Hiredate varchar(30),Salary int,Department_id int); insert into Employee_details values(7369,"Smith","Jon","Q",667,7902,"17-Dec-84",800,10), (7499,"Allen","Kevin","J",670,7698,"20-Feb-85",1600,20),(7505,"Doyle","Jean","K",671,7839,"04-Apr- 85",2850,20), (7506,"Dennis","Lynn","S",671,7839,"15-May-85",2750,30),(7507,"Baker","Leslie","D",671,7839,"10-June- 85",2200,40), (7521,"wark","cynthia","D",670,7698,"22-Feb-85",1250,10); select* from Employee_details; select Firstname,Middlename,Lastname from Employee_details; select* from Employee_details where Lastname LIKE 'S%' AND Middlename = "Q"; UPDATE Employee_details SET Salary = Salary+(Salary*10/100); Delete from Employee_details; 17. Empno ename job hiredate sal deptno 11 Anish salesman 29/2/2000 10000 30 12 Harini salesman 2/11/2019 8000 30 13 Payal manager 10/3/2015 15000 40 14 Trushna analysts 22/1/2020 13000 20 15 Priyanka manager 6/9/2019 14000 40 16 Komal president 20/4/2015 10000 10 17 Dinesh clerk 2/12/2018 1000 15 18 Amol clerk 30/7/2015 850 15 Displays today’s Date And Time by using Built in functions. Display time, date and day separately using Built in functions. Find sum of Salaries of clerks in the employee table. Display total number of Clerks in organization. Find the sum of salaries of employees. create database employee; use employee; create table emp(Empno int,ename varchar(20),job varchar(20),hiredate DATE,sal int,deptno int,primary key(Empno)); show tables; desc emp; insert into emp values(11,'Anish','salesman',"2000-02-29",10000,30); insert into emp values(12,'Harini','salesman',"2019-11-02",8000,30); insert into emp values(13,'Payal','manager',"2015-03-10",15000,40); insert into emp values(14,'Trushna','analyst',"2020-01-22",13000,20); insert into emp values(15,'Priyanka','manager',"2019-09-06",14000,40); insert into emp values(16,'Komal','president',"2015-04-20",10000,10); insert into emp values(17,'Dinesh','clerk',"2018-12-02",1000,15); insert into emp values(18,'Amol','clerk',"2015-07-30",850,15); select * from emp; select now(); select current_time(); select current_date(); select day(curdate()); select job, sum(sal) from emp where job = 'clerk'; select count(ename) from emp where job ='clerk'; select sum(sal) from emp; 18. Empno ename job hiredate sal deptno 11 Anish salesman 29/2/2000 10000 30 12 Harini salesman 2/11/2019 8000 30 13 Payal manager 10/3/2015 15000 40 14 Trushna analysts 22/1/2020 13000 20 15 Priyanka manager 6/9/2019 14000 40 16 Komal president 20/4/2015 10000 10 17 Dinesh clerk 2/12/2018 1000 15 18 Amol clerk 30/7/2015 850 15 Display Average Salary of employees. Find the total no. of employees Display total no. of unique job types. Display total no. of characters in the longest employee name Find out sum of salaries of each department create database employee; use employee; create table emp(Empno int,ename varchar(20),job varchar(20),hiredate DATE,sal int,deptno int,primary key(Empno)); show tables; desc emp; insert into emp values(11,'Anish','salesman',"2000-02-29",10000,30); insert into emp values(12,'Harini','salesman',"2019-11-02",8000,30); insert into emp values(13,'Payal','manager',"2015-03-10",15000,40); insert into emp values(14,'Trushna','analyst',"2020-01-22",13000,20); insert into emp values(15,'Priyanka','manager',"2019-09-06",14000,40); insert into emp values(16,'Komal','president',"2015-04-20",10000,10); insert into emp values(17,'Dinesh','clerk',"2018-12-02",1000,15); insert into emp values(18,'Amol','clerk',"2015-07-30",850,15); select * from emp; select avg(sal) from emp; select count(ename) from emp; select distinct( job) from emp; select count(distinct job) from emp; select max(length(ename)) as longest_emp_name from emp; select job, sum(sal) from emp group by job; 19. Empno ename job hiredate sal deptno 11 Anish salesman 29/2/2000 10000 30 12 Harini salesman 2/11/2019 8000 30 13 Payal manager 10/3/2015 15000 40 14 Trushna analysts 22/1/2020 13000 20 15 Priyanka manager 6/9/2019 14000 40 16 Komal president 20/4/2015 10000 10 17 Dinesh clerk 2/12/2018 1000 15 18 Amol clerk 30/7/2015 850 15 Find the maximum salary . Find the minimum salary Display department number and sum of salary for those departments where sum of salaries of those departments is greater than 9000. Display Department number and total strength of salesman in that department where strength exceeds 1. Display maximum salary paid in each department create database employee1; use employee1; create table emp(Empno int,ename varchar(20),job varchar(20),hiredate DATE,sal int,deptno int,primary key(Empno)); show tables; desc emp; insert into emp values(11,'Anish','salesman',"2000-02-29",10000,30); insert into emp values(12,'Harini','salesman',"2019-11-02",8000,30); insert into emp values(13,'Payal','manager',"2015-03-10",15000,40);