CREATE DATABASE StoreDB;

USE StoreDB;

CREATE TABLE Products (
    ProductID INT AUTO_INCREMENT PRIMARY KEY,
    ProductName VARCHAR(50) NOT NULL,
    PricePerUnit DECIMAL(10, 2) NOT NULL,
    Quantity INT NOT NULL
);

INSERT INTO Products (ProductName, PricePerUnit, Quantity)
VALUES
('Laptop', 50000.00, 10),
('Mobile', 20000.00, 20),
('Tablet', 15000.00, 15);

DELIMITER //
CREATE FUNCTION CalculateTotalPrice(price DECIMAL(10, 2), qty INT) 
RETURNS DECIMAL(10, 2)
DETERMINISTIC
BEGIN
    RETURN price * qty;
END;
//
DELIMITER ;

SELECT ProductName, PricePerUnit, Quantity,
    CalculateTotalPrice(PricePerUnit, Quantity) AS TotalPrice FROM Products;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: