DBMS Practical File
DBMS Practical File
DBMS PRACTICALS
In MS SQL Server
Saurabh Verma
M.SC OPERATIONAL RESEARCH
3ED SEMESTER SECTION A
DEPARTMENT OF OPERATIONAL RESEARCH
UNIVERSITY OF DELHI
DBMS PRACTICALS
Select*
From student
ORDER BY IDno DESC;
SAURABH VERMA 1
DBMS PRACTICALS
Select IDno,name,Marks1,Marks2,Marks3,Marks4,Marks5,((Marks1+Marks2+Marks3+Marks4+Marks5)/5) as
percentage
From student
group by IDno,name,Marks1,Marks2,Marks3,Marks4,Marks5
ORDER BY percentage;
Select IDno,name,Marks1,Marks2,Marks3,Marks4,Marks5,((Marks1+Marks2+Marks3+Marks4+Marks5)/5) as
percentage
From student
Where ((Marks1+Marks2+Marks3+Marks4+Marks5)/5)>=80.00
group by IDno,name,Marks1,Marks2,Marks3,Marks4,Marks5
Order by IDno;
Select *
From student
Where ((Marks1+Marks2+Marks3+Marks4+Marks5)/5)>=80.00
Order by IDno;
SAURABH VERMA 2
DBMS PRACTICALS
select*from customer;
Table2 PARTS
select*from parts;
SAURABH VERMA 3
DBMS PRACTICALS
Table3 ORDERS
select*from orders;
Create the above three table and populate the given data and perform the following queries in SQL:
i.Find out order details of parts having description like ‘Road____’.
SAURABH VERMA 4
DBMS PRACTICALS
Select *
From orders
Where (partnum in (Select partnum From parts Where description like 'Road%'));
iii.Find out the details(customername,data orderedon,totalvalue) of those customers whose order value is
more average order value .[totalvalue=quantity*price]
iv.Alter table ORDERS to add one more column Remarks and update the value as ‘paid’ for all the records.
Update orders
set Remarks = 'Paid';
select*from orders;
SAURABH VERMA 5
DBMS PRACTICALS
Table4 Employee
select*from Employee;
SAURABH VERMA 6
DBMS PRACTICALS
Table5 Department
select*from Department;
i.Retrieve the data of birth and salary of the employee(s) whose name is ‘Priya’.
select BDATE,SALARY
FROM Employee
where FNAME = 'Priya';
ii.Retrieve the name of all employee who work for the ‘Research’ department.
SAURABH VERMA 7
DBMS PRACTICALS
iii.Select all combination of employee number and department name in the database.
select ENG,DNAME
FROM Employee,Department;
iv.Find the sum of the salaries of all the employees of the ‘Research’ department as well as the maximum
salary, the minimum salary and the average salary in the department.
SAURABH VERMA 8
DBMS PRACTICALS
v.For each department , retrieve the department number,the number of employees in the department and
their average salary.
select DNAME,COUNT(SALARY),AVG(SALARY)
FROM Employee,Department
where DNO=DNUMBER
GROUP BY DNAME;
select*from CLUB;
SAURABH VERMA 9
DBMS PRACTICALS
sp_help CLUB;
iii.List the names of all the coaches with their date of joining in descending order.
SELECT *
FROM CLUB
ORDER BY DATE_OF_JOINING desc;
SAURABH VERMA 10
DBMS PRACTICALS
iv.Display a report, showing coach name ,pay, age and bouns (15%of pay) for all the coaches.
v.Display the name ,ID and age of all coaches with salary>5000.
SELECT COACH_NAME,COACH_ID,AGE
FROM CLUB
WHERE PAY>5000;
SAURABH VERMA 11
DBMS PRACTICALS
Q5.A departmental store deals in a variety of products perishable and non-perishable.Create a database
using two tables to store the details for product.
SAURABH VERMA 12
DBMS PRACTICALS
i.Display a list of item that are perishable and whose expiry date has passed
SELECT *
FROM PRO_INFO I,PRO_STOCK S
WHERE I.PERISHABLE='YES' AND S.DATA_OF_EXP<='04-SEP-2019' AND I.U_P_ID=S.U_P_ID;
iii.Display the details of all products with Rate b/n any 2 limits
SELECT *
FROM PRO_INFO I,PRO_STOCK S
WHERE I.U_P_ID=S.U_P_ID AND RATE>15 AND RATE<600;
SAURABH VERMA 13
DBMS PRACTICALS
v.Display those product categories with their avg rate which are having avg rate greater then 500
SAURABH VERMA 14