CREATE TABLE Employee (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(50)
);
CREATE TABLE Customer (
CustomerID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50)
);
CREATE TABLE Orderss (
OrderID INT PRIMARY KEY,
CustomerID INT,
OrderDate DATE,
Amount DECIMAL(10, 2),
FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID) -- ❗ Fixed table name
);
insert into Customer values(32,'n','b');
insert into Customer values(78,'n','b');
insert into Customer values(98,'n','b');
insert into Orderss values(45,32,'2024-09-09',8.9);
-- Write a function that takes OrderID and returns the number of days since
-- that order was placed.
-- Write a function that returns the discounted price
-- (given price and discount percentage).
-- Create a function that returns the number of employees in a given department.
-- Write a function that returns the last name of a customer based on their ID.
-- Create a function to return the maximum order amount placed by any customer.
-- Write a procedure to insert a new employee into the Employees table.
-- Write a procedure to update an employee’s department.
-- Create a procedure to delete all orders of a specific customer.
delimiter //
create procedure p(in id int)
begin
delete from Orderss where
CustomerID=id;
end; //
delimiter ;
call p(32);
-- Write a procedure that takes CustomerID and returns the total number of their orders.
-- Create a procedure to return a list of all employees in a specific department.
-- Write a procedure that returns total sales between two given dates.
-- Create a procedure to insert a new order for a customer.
-- Write a procedure that prints the full names of all customers.
-- Create a procedure to find customers who have not placed any orders.
-- Write a procedure to return the top 3 customers with the highest total order amount.