Compilation of Lab Exercises
Compilation of Lab Exercises
Creation of Database
II. Creation of Table
III. Insert 10 records
IV. Update Multiple Records
V. Update a Record
VI. Update all Records
VII. Delete a Record
VIII. Delete All Records
IX. Delete a table
INTEGRITY CONSTRAINTS
2. Full Join
SELECT Students.student_id, Students.student_name, Courses.course_id, Courses.course_name
FROM Students
FULL JOIN Courses
ON Students.course_id = Courses.course_id;
6. Right Join
SELECT Students.student_id, Students.student_name, Courses.course_id, Courses.course_name
FROM Students
RIGHT JOIN Courses
ON Students.course_id = Courses.course_id;
2. Product Pricing:
Scenario: Find products with prices higher than the average price across all categories.
Query: Utilize a subquery to calculate the average price and filter products based on this value.
3. Customer Orders:
Scenario: Identify customers who made more than three orders in the past month.
Query: Use a subquery to count the number of orders for each customer and filter the results
accordingly.
4. Healthcare Management:
Scenario: Retrieve patient details along with their most recent diagnosis.
Query: Utilize a subquery to find the latest diagnosis date for each patient and join this
information with the patient details.
5. Inventory Replenishment:
Scenario: Identify products that need to be reordered by finding those with quantities below a
certain threshold.
Query: Use a subquery to filter products based on their stock levels.
6. Marketing Analysis:
Scenario: Find customers who have purchased more than once and determine which products
they bought.
Query: Utilize a subquery to identify repeat customers and then join this information with the
products they purchased.
7. Project Management:
Scenario: Retrieve details of projects where the budget exceeds the average budget for projects in
the same category.
Query: Use a subquery to calculate the average budget for each project category and filter
projects accordingly.
9. Educational Institution:
Scenario: Retrieve a list of students who scored higher than the average score in a particular
subject.
Query: Use a subquery to calculate the average score and compare it with individual student
scores.
10. Supplier Evaluation:
Scenario: Identify suppliers with a rating higher than the average supplier rating.
Query: Utilize a subquery to calculate the average supplier rating and filter suppliers accordingly.