MySQL Assignment Questions

Published: 09 Apr, 2025
Category Assignment Subject Education
University ______ Module Title MySQL Assignment

MySQL Assignment Questions

Q1. SELECT clause with WHERE, AND, DISTINCT, Wild Card (LIKE)

a. Fetch the employee number, first name and last name of those employees who are working as Sales Rep reporting to employee with employee number 1102 (Refer employee table)

Expected output:

MySQL Assignment

b. Show the unique productline values containing the word cars at the end from the products table.

Expected output:

MySQL Assignment]

Q2. CASE STATEMENTS for Segmentation

.a. Using a CASE statement, segment customers into three categories based on their country:(Refer Customers table)

  • "North America" for customers from USA or Canada
  • "Europe" for customers from UK, France, or Germany
  • "Other" for all remaining countries
  • Select the customerNumber, customerName, and the assigned region as "CustomerSegment".

Expected output:

MySQL Assignment

Buy Answer of MySQL Assignment & Raise Your Grades

Order Non Plagiarized Assignment

Q3. Group By with Aggregation functions and Having clause, Date and Time functions

a. Using the Order Details table, identify the top 10 products (by productCode) with the highest total order quantity across all orders.

Expected output:

MySQL Assignment

b. Company wants to analyse payment frequency by month. Extract the month name from the payment date to count the total number of payments for each month and include only those months with a payment count exceeding 20. Sort the results by total number of payments in descending order. (Refer Payments table).

Expected output:

MySQL Assignment

Q4. CONSTRAINTS: Primary, key, foreign key, Unique, check, not null, default

Create a new database named and Customers_Orders and add the following tables as per the description

a. Create a table named Customers to store customer information. Include the following columns:

  • customer_id: This should be an integer set as the PRIMARY KEY and AUTO_INCREMENT.
  • first_name: This should be a VARCHAR(50) to store the customer's first name.
  • last_name: This should be a VARCHAR(50) to store the customer's last name.
  • email: This should be a VARCHAR(255) set as UNIQUE to ensure no duplicate email addresses exist.
  • phone_number: This can be a VARCHAR(20) to allow for different phone number formats.

Add a NOT NULL constraint to the first_name and last_name columns to ensure they always have a value.

b. Create a table named Orders to store information about customer orders. Include the following columns:

  • order_id: This should be an integer set as the PRIMARY KEY and AUTO_INCREMENT.
  • customer_id: This should be an integer referencing the customer_id in the Customers table  (FOREIGN KEY).
  • order_date: This should be a DATE data type to store the order date.
  • total_amount: This should be a DECIMAL(10,2) to store the total order amount.

Constraints:

  1. Set a FOREIGN KEY constraint on customer_id to reference the Customers table.
  2. Add a CHECK constraint to ensure the total_amount is always a positive value.

Achieve Higher Grades This Assignment Solutions

Order Non Plagiarized Assignment

Q5. JOINS

a. List the top 5 countries (by order count) that Classic Models ships to. (Use the Customers and Orders tables)

Expected output:

MySQL Assignment

Q6. SELF JOIN

a. Create a table project with below fields.

  • Employee ID : integer set as the PRIMARY KEY and AUTO_INCREMENT.
  • Full Name: varchar(50) with no null values
  • Gender : Values should be only ‘Male’  or ‘Female’
  • Manager ID: integer 

Add below data into it.

MySQL Assignment

Find out the names of employees and their related managers.

Expected output:

MySQL Assignment

Q7. DDL Commands: Create, Alter, Rename

a. Create table facility. Add the below fields into it.

  • Facility_ID
  • Name
  • State
  • Country
  1. Alter the table by adding the primary key and auto increment to Facility_ID column.
  2. Add a new column city after name with data type as varchar which should not accept any null values.

MySQL Assignment

Q8. Views in SQL

a. Create a view named product_category_sales that provides insights into sales performance by product category. This view should include the following information:

  • productLine: The category name of the product (from the ProductLines table).
  • total_sales: The total revenue generated by products within that category (calculated by summing the order Details.quantity * order Details.priceEach for each product in the category).
  • number_of_orders: The total number of orders containing products from that category.
  • (Hint: Tables to be used: Products, orders, orderdetails and productlines)

The view when read should show the output as:

MySQL Assignment

Q9. Stored Procedures in SQL with parameters

a. Create a stored procedureGet_country_payments which takes in year and country as inputs and gives year wise, country wise total amount as an output. Format the total amount to nearest thousand unit (K)

Tables: Customers, Payments

Expected output:

MySQL Assignment

Do You Need Assignment of This Question

Order Non Plagiarized Assignment

Q10. Window functions - Rank, dense_rank, lead and lag

a) Using customers and orders tables, rank the customers based on their order frequency

MySQL Assignment

b) Calculate year wise, month name wise count of orders and year over year (YoY) percentage change. Format the YoY values in no decimals and show in % sign.

Table: Orders

Expected output:

Q10. Window functions - Rank, dense_rank, lead and lag

Q11. Subqueries and their applications

a. Find out how many product lines are there for which the buy price value is greater than the average of buy price value. Show the output as product line and its count.

Expected output:

MySQL Assignment

Q12. ERROR HANDLING in SQL

Create the table Emp_EH. Below are its fields.

  • EmpID (Primary Key)
  • EmpName
  • EmailAddress

Create a procedure to accept the values for the columns in Emp_EH. Handle the error using exception handling concept. Show the message as “Error occurred” in case of anything wrong.

Q13. TRIGGERS

Create the table Emp_BIT. Add below fields in it.

  • Name
  • Occupation
  • Working_date
  • Working_hours

Insert the data as shown in below query.

INSERT INTO Emp_BIT VALUES
('Robin', 'Scientist', '2020-10-04', 12),  
('Warner', 'Engineer', '2020-10-04', 10),  
('Peter', 'Actor', '2020-10-04', 13),  
('Marco', 'Doctor', '2020-10-04', 14),  
('Brayden', 'Teacher', '2020-10-04', 12),  
('Antonio', 'Business', '2020-10-04', 11);

Create before insert trigger to make sure any new value of Working_hours, if it is negative, then it should be inserted as positive.

Buy Answer of This Assignment & Raise Your Grades

Order Non Plagiarized Assignment

Need help on MySQL Assignment? Here the best solution for you our expert team are providing Assignment Help. Here you will get all the services and that too at affordable prices. What you need Apart from university assignment help we also provide free assignment samples specifically for UK students which will help you in understanding how an assignment is written. Trust us and give your assignment to us to write. We will deliver your assignment before the deadline. Contact us today and boost your academic grads!

AC4006 T1 Fundamentals of Business Accounting Assessment Guide/Coursework Question

AC4006: Fortunate Ltd operates in the United Kingdom (UK) and sells Product A - a perishable food item, which is ordered from suppliers. They also specialise in the manufacture and sale of Product B.

BTEC Unit 23: Financial Management Assignment 2 Question 2025

BTEC Unit 23: LO3. Evaluate approaches to working capital management within an organization.  LO4. Recommend alternative investment appraisal techniques to inform decision making.

Strategic Management & Leadership Assignment Brief 2025

Strategic Management & Leadership Assignment: Critically discuss the role of leadership in developing and implementing strategy and innovation within healthcare organisations.

MW4043 Public Health& Wellbeing Strategies and Interventions Assessment Brief | UCLan

MW4043 Assessment Brief: ‘Develop a proposal for a health education and behaviour change initiative on an appropriate public health topic aimed at a small and specific population group’.

Unit 1: Professional Practice in the Digital Economy Assignment Brief 2025

Unit 1: LO1: Explore the evolution and impact of digital technologies on work environments. LO2: Examine the importance of professional development for career success

44-508607 Personal and Professional Development Portfolio Assignment Brief 2025

The aim of this assessment is to support students to become independent and reflective practitioners; knowledgeable of the requirements to work within their chosen sector and able to demonstrate the skills to develop themselves

SG7001 Strategy, Operations and Partnerships Assignment Brief Apr 2025

In this module, you will learn how to create, evaluate, and improve a business strategy and its operations. You will also learn about the challenges and practices of a strategic manager and how organisations manage their day-to-day activities.

7102MAA CW2 Assignment Brief Apr 2025 : Sustainability & Green Logistics

Prepare a 10 MINUTE (maximum) Individual Poster [PowerPoint] Presentation with embedded Audio Recording to demonstrate your knowledge and understanding of key Sustainability and Green Logistics theories and concepts through critical argument, analyses, and evaluation.

Study for Success/Communication Coursework Assessment Brief | BPP

Reflection is an important activity that allows you to think about your development and enhance your practice. As part of your term 0 learning, you are encouraged to keep a reflective journal.

BSP5071 Business In Action Assessment 02 Brief | CMU

Showcase research and understanding of your chosen topic (Business Ownership, Functions, Structure, Environment, or Digitalisation) Apply a Reflective Model to analyse preparation, contributions, and actions

Online Assignment Help in UK