Professional Documents
Culture Documents
Databases
Databases
Databases
Stage 2, Semester 1
2022
Instructions:
Save your answer in a Microsoft Word document and submit the file through
Moodle.
Topic:
MySQL, Data definition language (DDL), Data Manipulation Language (DML)
24130 Joelma Rodrigues 24130@student.dorset-college.ie
You are given an eCommerce database as a MySQL SQL script. Please import the database
into the database through either MySQL Workbench or command line client. You then
need to answer the following questions regarding to this database.
Using SQL command to find out the answers for the following question. You need to
provide both the SQL and the answer.
Page 2 of 9
24130 Joelma Rodrigues 24130@student.dorset-college.ie
Q 3. List all employee with their full name and job title.
[5 Marks]
select firstname, lastname, jobtitle from employees;
[5 Marks]
select count(jobtitle) from employees
where jobtitle = 'Sales Rep';
Page 3 of 9
24130 Joelma Rodrigues 24130@student.dorset-college.ie
Q 5: List the customers whose credit limit is between 80 000.00 and 120 000.00.
[5 Marks]
select customerName, creditLimit from customers
where creditLimit between 80000 and 120000
order by creditLimit ASC;
Page 4 of 9
24130 Joelma Rodrigues 24130@student.dorset-college.ie
Q 6: List all customer who is from the city of NYC in country of USA, and their last names
begin with ‘L’ (tip: use contactLastName column).
[5 Marks]
Q 7: From Costumers table, list countries and the number of customers from each country
by the order of the greatest number of customers to less number of customers.
[5 Marks]
SELECT country, count(country) FROM customers
group by country
order by count(country) desc;
Q 8: From Payments table, list all customer number, check number and payment amount
where the amount is less than 2000.00 [5 Marks]
Q 9: From Payments table, calculate the total amount of all payments. [5 Marks]
Q 10: List the minimum, maximum and average payment amount in Payments table.
[5 Marks]
select MIN(amount) as min_amount, max(amount) as max_amount,
avg(amount) from payments;
Q 11: Find out how many payments have been made in November 2004 (paymentDate is
in November 2004). [5 Marks]
Page 6 of 9
24130 Joelma Rodrigues 24130@student.dorset-college.ie
Q 12: From Product table, list the distinct product lines and number of products within
each product where the number of products lines has quantity in store less than 50000.
[5 Marks]
Q 13: Display the details of the employees who are working in the offices located in
territory EMEA (hint: use subquery). [5 Marks]
Q 14: Display the number of products in each order and the average individual prices.
[5 Marks]
select productLine, count(productLine) from products
group by productLine;
Page 7 of 9
24130 Joelma Rodrigues 24130@student.dorset-college.ie
Q 16. Count how many employees working each office. [5 Marks]
Q 15: For each office has more than 3 employees working in them, list office codes, cities,
and number of employees in each of those offices. [5 Marks]
Q 17. List all employees who works in Boston and NYC. (Hint: use subquery) [5 Marks]
Page 8 of 9
24130 Joelma Rodrigues 24130@student.dorset-college.ie
Q 18. List all the products that their MSRP (manufacturer’s suggested retail price) is
greater than the average MSRP of all products, and display by how much is the difference.
[5 Marks]
Page 9 of 9