11.
Write the SQL commands for the questions
from (i) to (v) on the basis of table Employee.
(i) Display Employee Name and Salary of those employees
whose salary is greater
than or equal to 22000?
(ii) Display details of employees those are not getting
commission.
(iii) Display employee name and salary of those employees
who have their salary in range of 2000 to 4000?
(iv) Display the name, profile and salary of employee (s)
who doesn't have manager?
(i) Select E_name, Salary from Employee where
Salary>=22000
21
(ii) Select * from Employee where Commission= 'NULL'
(iii) SELECT "E_name", "Salary" FROM "Employee" WHERE
Salary between 2000 and 4000
(iv) SELECT "E_name", "Salary",Profile FROM "Employee"
WHERE Manager='NULL'
12. Create below table using DDL query and Insert at least 10
records. And write following queries on given table.
(i) Show list of all customers.
(ii) Display name of customer who sale item on date 2nd
November 2012.
22
(iii) Display customer name and phone no who are living in
‘Ghaziabad’
(iv) Display information of customer who bought more than
20 items.
(v) Display list of all customer and show result in sorted
manner on items bought.
(i) Select Customer_Name from Customer
(ii) Select "Customer_Name" from "Customer" where
"Sale_Date"=’02/11/12’
(iii) Select "Customer_name","Phone"
from Customer where
"Customer_Address"="Ghaziabad"
(iv) Select*from "Customer" where ItemsBought>20
13. Write the answers based on the following table:
Table:Employee
23
a. Suggest a suitable data type for the field Empid and
Name in the table Employee.
b. Write a query to display all the records of the table for
deptid = 101.
c. Add a new record with the following details: (‘7’,
‘Chetan’, 102, ‘MCA’, ‘M’)
a) Emp.id int
Name varchar
Dept.id int
Qualification varchar
Gender char
b) SELECT * from Employee where "Dept.id" = 101;
c) INSERT into Employee values(‘7’,‘Chetan’,‘102’,‘MCA’,‘M’);
14. Write the SQL commands to answer the queries based on
Fabric table.
24
i) To insert the following record (“F005”, “Kurta”,
“Woollen”,5)
ii). To display only those fabric whose disc is more than 10
iii). To display those records whose type is “Woollen”
iv). To modify the fabric shirt by increasing discount by 10
v). To delete the record of fabric ‘F003’ from table
i). INSERT into Fabric values(‘F005’, ‘Kurta’, ‘Woollen’,5);
ii). SELECT * from Fabric where Disc>10
iii). SELECT * from Fabric where Type=’Woolen’;
iv). UPDATE Fabric set Disc = 20 where Fname=’Shirt’;
v). DELETE * from Fabric where FabricID=’F003’;
15. Write SQL commands for the questions from (i) to (v) on
the basis of table SHOP.
25
i) Display all products whose quantity in between 100
and 400.
ii) Display data for all products sorted by their quantity.
iii) To list S_Name, P_Name, Cost for all the products
whose qu antity is less than 300.
iv) To display S_NO, P_Name, S_Name, Qty in descending
order of quantity from the SHOP table.
i) SELECT * FROM SHOP WHERE Qty BETWEEN 100 and
400;
ii) SELECT * FROM SHOP ORDER BY Qty;
iii) SELECT S_Name, P_Name, Cost FROM SHOP WHERE Qty
<300;
iv) SELECT S_NO, P_Name, S_Name, Qty FROM SHOP
ORDER BY Qty DESC;
26