DBMS__Lab3_SQL_exercises
DBMS__Lab3_SQL_exercises
1
Faculty of Data Science and Artificial Intelligence, NEU
1 Objective
The objective of this lab is to provide advanced hands-on practice with SQL queries using the classicmod-
els sample database. By the end of this lab, students will be proficient in using various SQL keywords
and concepts.
2 Foreword
Dear students,
Welcome to Lab 3: Advanced SQL Exercises! This lab is designed to help you practice and
reinforce your SQL skills using the classicmodels sample database. Make sure you have loaded the
classicmodels database into your MySQL server as instructed in the previous lab.
All the best,
Course Instructors
@DATCOM Lab 2
Faculty of Data Science and Artificial Intelligence, NEU
USE classicmodels;
SOURCE /path/to/mysqlsampledatabase.sql;
Replace /path/to/mysqlsampledatabase.sql with the actual path to the provided SQL file.
• Verify the data has been loaded by listing the tables:
SHOW TABLES;
5 Exercises
5.1 Exercise 1: Basic Select and From
Write a SQL query to retrieve all records from the customers table. Display the customer number,
name, and country.
@DATCOM Lab 3
Faculty of Data Science and Artificial Intelligence, NEU
5.9.2 ROLLUP
Write a SQL query to calculate the total sales per year, with a grand total at the end, using the ROLLUP
function.
@DATCOM Lab 4
Faculty of Data Science and Artificial Intelligence, NEU
5.10.3 EXISTS
Write a SQL query to find all customers who have placed at least one order.
6 Submission Instructions
• Write your SQL queries for each exercise and save them in a single SQL file named ID Lab3 Exercises.sql
(replace ID with your student ID).
• Ensure all queries are well-formatted and commented for clarity.
7 References
• MySQL Sample Database
@DATCOM Lab 5