You are on page 1of 36

1

Data Base Management System


Lab MCA-156








SUBMITTED BY
HIMANSHU KWATRA
05625104413
MCA 2
nd
SHIFT 1
st
YEAR



2

QUE- Write the queries to create following tables
Table 1: Dept_master


3

Table 2: Employee_master



4

Table 3: Vendor_master



5

Table 4: Material_master




6

Table 5: Order_master




7

QUE-1 Write a query to select the vendor id, name and phone no.
of vendor who lives in the state of u.p and rajasthan.
ANS- select vendor_id,vendor_name,phone from vendor_master
where state not in('U.P','rajesthan');


8


QUE-2 Write a query to select the name and address of vendor
whose name contain the letter %a%.
ANS- select Vendor_name,Vendor_Address from Vendor_master
where Vendor_name like '%a%';

9




10

QUE-3 Write a query to count the no. of vendors who fall in the
state of uttar pradesh If the no.of vendors in the state of
uttar pradesh are 3, the result should be as No. of vendors in
the state of uttar pradesh is 3.
ANS- select count(*)'No. of vendors in state uttar prdesh is'
from vendor_master where state like 'UP%';



11



4- QUE-4 Write a query to list the details of vendors who does
not belong to the state of uttar Pradesh
ANS-
select Vendor_id,Vendor_name,Vendor_Address,City,Pincode,Phone
from Vendor_master where State not like 'U.P%';


12





13


QUE5- Write a query to select the vendor id, name and state of
the vendor whose address field has a . Contained in it
ANS- select vendor_id,vendor_name,Vendor_Address from
vendor_master where State like '%.%';





14



6- Write a query to list the material id, its description and
stock available for those whose unit price falls above 600 but
less than 900.
ANS- select Material_id,Material_desc,stock from material_master
where unit_price between 600 and 900;




15








16

7-Write a query to display the information of a material whose
unit price is either 450.25 or 500 or 700 or 900.
ANS- select * from material_master where unit_price
in(450.25,500,900,700);





17



Q8 Write a query to display the information about the material
value in the stock is less than 5.
ANS- select * from material_master where stock<5;



18




19

Q.9 Write a query to change the address1 of vendor to 186,
circular no. 2 whose vendor_id is v1001.
ANS- update vendor_master set Vendor_Address='186, circular no.2'
where vendor_id='v1001';





20





Q10. Modify the date of birth to 23-aug-67 where employee id is
e10126.
ANS- update Employee_master1 set Dateofbirth='23-08-1967' where
Employee_no='e10126';


21







22

Q11. Write a query to display the names of all employees whose
commission is more than 10% of their basic salary and falls in
the category of salesman.
ANS-select Employee_name from Employee_master1 where
commission>0.10*Emp_Basic and designation='sales manager';




23




Q12. Write a query to select the employee no. and name of those
employees who earn salary more than the average salary of all
the employees working in the organization.
ANS- select Employee_no,Employee_name from Employee_master1
where Emp_Basic>(select avg(Emp_Basic)from Employee_master1);



24






25

Q13. Write a query to select the minimum, maximum and average
salary of the employees working in the organization. The
headings should be smi, smx and sav respectively.
ANS- select min(Emp_Basic) "smi", max(Emp_Basic) "smx",
avg(Emp_Basic) "sav" from Employee_master1;




26


Q14. Write a query to inform you about the no. of employees
working for each department.
ANS- select count(*) "Count" from Employee_master1 group by
dept_no;

27




28

Q15. Write a query to display the name, designation, department
name and location who does not work in the Kanpur office.
ANS- select
Employee_name,Designation,Department_name,Department_location
from Dept_master1 where department_location!='kanpur';


29



Q16. Write a query to list the name and id of all employees in
alphabetical order of their name.
ANS- select Employee_name,Employee_no from Employee_master1 order
by employee_name;

30



31

Q17. Write a query to select the name and basic salary of
employees who have a letter e ors in their names. Further,
modify the query list for those who does not contain m in
their names.
ANS- select Employee_name,Emp_basic from Employee_master1 where
employee_name like '%e%' or Employee_name like '%s%' ;
select * from Employee_master1;
select employee_name,Emp_Basic from Employee_master1 where
employee_name not like '%m%' ;
select * from Employee_master1;



32





33




Q18. Write a query to list the id, name and department no. of
employees who are born in the month of February.
ANS- select employee_no,employee_name,dept_no,dateofbirth from
Employee_master1 where dateofbirth like('%FEB%');




34




35

Q19. Write a query to select the name and date of birth of those
employees who are born before February 7, 1976.
ANS- select employee_name,dept_no from Employee_master1 where
dateofbirth<'7-02-1976';



36

You might also like