Buat Database Penjualan DB_Penjualan
CREATE DATABASE DB_Penjualan;
Tabel : Jenis_Barang
CREATE TABLE Jenis_Barang(
KodeJenisBarang Varchar(10),
JenisBarang Varchar (50),
JumlahPembelian Integer,
PRIMARY KEY (KodeJenisBarang)
);
INSERT INTO Jenis_Barang (KodeJenisBarang, JenisBarang, JumlahPembelian)
Values ('DD888A','Alat Tulis', 8),
('DD888F','Alat Tulis', 5),
('DD888B','Elektronik', 7),
('DD888K','Elektronik', 3),
('DD888C','Makanan', 6),
('DD888Q','Makanan', 1);
select * from Jenis_Barang;
Tabel : Pembelian
CREATE TABLE Pembelian(
KodeJenisBarang Varchar(10),
JumlahPembelian Integer,
TotalHarga Varchar (50),
PRIMARY KEY (KodeJenisBarang)
);
INSERT INTO Pembelian (KodeJenisBarang, JumlahPembelian, TotalHarga)
Values ('DD888A', 8, 'Rp. 12.000'),
('DD888F', 5, 'Rp. 10.000'),
('DD888B', 7, 'Rp. 350.000'),
('DD888K', 3, 'Rp. 900.000'),
('DD888C', 6, 'Rp. 30.000'),
('DD888Q', 1, 'Rp. 9.000');
select * from Pembelian;
from Jenis_Barang as a join Pembelian
as b on a.KodeJenisBarang = b.KodeJenisBarang where b.JumlahPembelian>5;
EmoticonEmoticon