fork download
  1. -- Product টেবিল তৈরি
  2. CREATE TABLE Product (
  3. ProductID INT PRIMARY KEY,
  4. ProductName VARCHAR(100) NOT NULL,
  5. Category VARCHAR(50),
  6. Price DECIMAL(10,2) NOT NULL,
  7. Stock INT NOT NULL
  8. );
  9.  
  10. -- Sell টেবিল তৈরি
  11. CREATE TABLE Sell (
  12. SellID INT PRIMARY KEY,
  13. ProductID INT,
  14. Quantity INT NOT NULL,
  15. SellDate DATE NOT NULL,
  16. FOREIGN KEY (ProductID) REFERENCES Product(ProductID)
  17. );
  18.  
  19. -- Product ডাটা ইনসার্ট
  20. INSERT INTO Product (ProductID, ProductName, Category, Price, Stock)
  21. VALUES
  22. (1, 'Smart T-Shirt', 'Clothing', 450.00, 50),
  23. (2, 'Smart Jeans', 'Clothing', 1200.00, 30),
  24. (3, 'Sneakers', 'Footwear', 2500.00, 20),
  25. (4, 'Cap', 'Accessories', 300.00, 100);
  26.  
  27. -- Sell ডাটা ইনসার্ট
  28. INSERT INTO Sell (SellID, ProductID, Quantity, SellDate)
  29. VALUES
  30. (101, 1, 20, '2025-08-01'),
  31. (102, 1, 15, '2025-08-03'),
  32. (103, 2, 5, '2025-08-04'),
  33. (104, 3, 10, '2025-08-05'),
  34. (105, 4, 12, '2025-08-06'),
  35. (106, 4, 25, '2025-08-07');
  36.  
  37. -- প্রশ্ন ২: 'Smart' নাম আছে এমন প্রোডাক্টের সেল ডিটেইলস
  38. SELECT
  39. s.SellID,
  40. p.ProductName,
  41. s.Quantity,
  42. s.SellDate,
  43. (s.Quantity * p.Price) AS TotalPrice
  44. FROM Sell s
  45. JOIN Product p ON s.ProductID = p.ProductID
  46. WHERE p.ProductName LIKE '%Smart%';
Success #stdin #stdout 0.03s 25924KB
stdin
Standard input is empty
stdout
-- Product টেবিল তৈরি
CREATE TABLE Product (
    ProductID INT PRIMARY KEY,
    ProductName VARCHAR(100) NOT NULL,
    Category VARCHAR(50),
    Price DECIMAL(10,2) NOT NULL,
    Stock INT NOT NULL
);

-- Sell টেবিল তৈরি
CREATE TABLE Sell (
    SellID INT PRIMARY KEY,
    ProductID INT,
    Quantity INT NOT NULL,
    SellDate DATE NOT NULL,
    FOREIGN KEY (ProductID) REFERENCES Product(ProductID)
);

-- Product ডাটা ইনসার্ট
INSERT INTO Product (ProductID, ProductName, Category, Price, Stock)
VALUES
(1, 'Smart T-Shirt', 'Clothing', 450.00, 50),
(2, 'Smart Jeans', 'Clothing', 1200.00, 30),
(3, 'Sneakers', 'Footwear', 2500.00, 20),
(4, 'Cap', 'Accessories', 300.00, 100);

-- Sell ডাটা ইনসার্ট
INSERT INTO Sell (SellID, ProductID, Quantity, SellDate)
VALUES
(101, 1, 20, '2025-08-01'),
(102, 1, 15, '2025-08-03'),
(103, 2, 5, '2025-08-04'),
(104, 3, 10, '2025-08-05'),
(105, 4, 12, '2025-08-06'),
(106, 4, 25, '2025-08-07');

-- প্রশ্ন ২: 'Smart' নাম আছে এমন প্রোডাক্টের সেল ডিটেইলস
SELECT 
    s.SellID,
    p.ProductName,
    s.Quantity,
    s.SellDate,
    (s.Quantity * p.Price) AS TotalPrice
FROM Sell s
JOIN Product p ON s.ProductID = p.ProductID
WHERE p.ProductName LIKE '%Smart%';