#MySQL #tutorial #course
You can copy and paste all of the following statements if you would like to follow along in this video.
P.S. Make sure you have a customers table if you're linking the foreign key on customer_id.
------------------------------------------------------------
DROP TABLE IF EXISTS transactions;
CREATE TABLE transactions (
transaction_id INT PRIMARY KEY AUTO_INCREMENT,
amount DECIMAL(5, 2),
customer_id INT,
order_date DATE,
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id)
);
INSERT INTO transactions
VALUES (1000, 4.99, 3, "2023-01-01"),
(1001, 2.89, 2, "2023-01-01"),
(1002, 3.38, 3, "2023-01-02"),
(1003, 4.99, 1, "2023-01-02"),
(1004, 1.00, NULL, "2023-01-03"),
(1005, 2.49, 4, "2023-01-03"),
(1006, 5.48, NULL, "2023-01-03");
SELECT * FROM transactions;
------------------------------------------------------------
00:00:00 intro
00:00:16 data for this demo
00:00:00 GROUP BY
00:03:19 HAVING
00:04:36 conclusion