-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_table.sql
44 lines (39 loc) · 850 Bytes
/
base_table.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--Create base table
create table base_table as(select
pjl.id_invoice,
pjl.tanggal,
pjl.id_customer,
plg.nama,
pjl.id_distributor,
pjl.id_cabang,
plg.cabang_sales,
plg.id_group,
plg.group,
pjl.id_barang,
brg.nama_barang,
pjl.brand_id,
brg.kode_lini,
pjl.lini,
brg.kemasan,
pjl.jumlah_barang,
pjl.harga,
pjl.mata_uang
from penjualan as pjl
left join pelanggan as plg on plg.id_customer = pjl.id_customer
left join barang as brg on brg.kode_barang = pjl.id_barang)
order by pjl.tanggal;
--Adding Primary Key constraint
alter table base_table
add primary key (id_invoice);
--For checking
select *
from base_table;
select *
from penjualan
limit 2;
select *
from barang
limit 2;
select *
from pelanggan
limit 2;