Lab 6 by Saad
Lab 6 by Saad
Lab 6 by Saad
By Mohammed Saadullah
(201851069)
Lab-B
Q2. Alter the table by modifying the column Name Describe the table employee as
employeeName
Ans.
Solving Queries
Q1. Develop a SQL query to list details of Departments that offer more than 3 branches.
Ans.
SELECT Dno,Dname,count(Bcode) as Branches FROM Branch natural join Department
GROUP BY Dno
having Branches>3;
Q2. Develop a SQL query to list the details of Departments that offer more than 6 courses.
Ans.
SELECT Dno,Dname,count(Ccode) as Courses FROM course natural join Departm
ent
GROUP BY Dno
having Courses>6;
Q3. Develop a SQL query to list the details of courses that are common for more than 3
branches.
Q4. Develop a SQL query to list students who got ‘S’ in more than 2 courses during single
enrollment.
Ans.
select rollno,name,count(sess) as CoursesFailed,sess FROM student natural
join Enrolls
where grade='S'
GROUP BY sess
having CoursesFailed>2;
Q5. Create a view that will keep track of the roll number, name and number of courses, a
student has completed successfully.
Q1. Develop DDL to implement above schema enforcing primary key, check constraints and foreign
key constraints.
Solving Queries
b.) Develop SQL query to list the details of customers who have placed more than 3 orders..
c.) Develop a SQL query to list details of items whose price is less than the average price of
all items in each order.
SELECT Orderno,Itemno,Item_name
from Order_Item natural join Average natural join Item
where unit_price< AVG_Order_Val;
d.) Develop a SQL query to list the orderno and number of items in each order.
e.) Develop a SQL query to list the details of items that are present in 25% of the orders.
Solving Queries