1. Write the outputs of SQL commands given in (h) with the help of the table shown. EmpNo Name Job Mgr Hiredate Sal Deptno Integer Character Character Float Date Float Integer  To select all the information of employee of Dept number 20  Find all employees who are either Clerks or who are earning between 1000 and 2000.  To list names of all employees in ascending order of their salary.  To display employee’s name, Salary, Deptno for only managers.  To count the number of employees with salary <3000.  To insert a new row in the Employee table with the following data: 11, “MILLER”, “Manager”, 7698, {25/02/98}, 4300, 20.  To display total salary department wise.  To display employees whose name starts with ‘C’  To display employees whose salary between 1000 to 5000 arranged on the basis of hiredate  Give the output of the following SQL statements: o Select COUNT(*) from Emp; o Select MIN(Sal) from Emp where deptno=20; o Select SUM(Sal) from Emp where job=’Clerk’; o Select AVG(sal) from Emp; o Select job,max(sal),min(sal),avg(sal) from emp group by job; o Select empno,ename,sal+comm “total Salary” from emp; o Select * from emp where hiredate<’ ‘ 12/12/  Consider a table Department having fields as Deptno Deptname Integer Character o Display name of employees along with their department having deptno as 10 or 20. o Display total salary of each department. o Display total salary of each department whose employee name starts with N or P. o Display total salary of each department whose total salary > 20000. 2. Write the SQL command for (a) to (f) on the basis of the table given below (Customer). Customer No. Fname Lname Phone Address Number(4) Character(20) Character(20) Number(8) Character(20)  Create the table  Enter following data

No 1 2 3 4 5 6 7 8

Fname Ajay Deepak Rajesh Priya Ramit Arpit Rahul Kisan

Lname Batra Chopra Mehta Kumar Arya Jain Kundra Kumar

Phone 27111333 25656891 23455511 23456334 24567565 23222334 24567856 27898981

Address Rohini Ashok Vihar Ashok Vihar Rohini Model Town Shailmar Bagh Model Town Rohini

 To select all the information of employee of Rohini area.  Update the database set the phone no. as 27111343 where phone number is 27111333.  To create a view called Dir with the following fields-> Fname, Phone and Address.  To display the data for Arpit, Rahul and Kisan.  To delete the rows where the address is Rohini.  Display record on the basis of Fname  Display number of records Create another table Sale No Itemcode Quantity Rate Number(4) Number(4) Number(7) Number(8,2) Add the following data No Itemcode Quantity Rate 1 1001 20 34.56 1 1002 30 67.56 3 1001 20 34.56 4 1009 13 359.23 5 1010 15 699.99 3 1008 16 345.34 Display Fname,Lname, amount paid(Quantity* Rate) from customer and sale tables Display total amount paid by each customer Display itemcode,fname, lname from cutomer and sale table Try this out and write the output Select No,count(*) from customer C, Sale S where C.No=S.No; Select * from customer where Fname loke ‘A%’ order by Address Select Fname, Quantity,Rate from Customer C, Sale S where C.No=S.No; Select No, Sum(quantity) from Sale group by No; Select No,Lname,sum(quantity) from customer C and Sale S group by No having a  To delete the tables physically.     1. 2. 3. 4. 5.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.