Tuesday, May 23, 2017

Membuat Nota Retur Jual

Membuat tabel Retur Jual

create table retur_jual(
No_retur varchar (10) primary key,
No_Notajual varchar (10),
Tgl_Retur date,
Jumlah_Retur int,
Ket_Cacat varchar (50),
foreign key (NoNota) references penjualan (Nonota))

1. isi data, ambil dari tabel penjualan, 2 record untuk di rektur

insert into retur_jual values
('RET001','JUAL001','2017/3/22',2,'rusak'),
('RET002','JUAL003','2017/4/19',10,'rusak')


2. browsing operasi matematika menggunakan SQL untuk penambahan stok barang

3. alternatif lain, update stok barang

update barang set jumlah=50+10 where KdBrg='BRG001'
update barang set jumlah=100+10 where KdBrg='BRG002'



4. jumlah retur tidak melebihi jumlah jual

5. tanggal retur tidak boleh sebelum tanggal jual

6. tambahkan 5 data retur

insert into retur_jual values 
('RET003','JUAL002','2017/04/19',8,'Rusak'),
('RET004','JUAL004','2017/04/03',1,'Rusak'),
('RET005','JUAL005','2017/05/12',4,'Rusak'),
('RET006','JUAL006','2017/05/23',5,'Rusak'),
('RET007','JUAL007','2017/06/08',2,'Rusak')


7. update data 3 retur

update retur_jual set Tgl_retur='2017/03/23' where No_retur='RET001'
update retur_jual set Ket_cacat='Kadaluarsa' where No_retur='RET002'
update retur_jual set Tgl_Retur='2017/04/20' where No_retur='RET003'


8. delete record 1 data retur

delete from retur_jual 
where No_retur='RET002'


9. tambahkan field jenis_paket

alter table retur_jual 
add jenis_paket varchar (20)


10. isi jenis paket 

update retur_jual set jenis_paket='JNE' where No_retur='RET001'
update retur_jual set jenis_paket='POS' where No_retur='RET003'
update retur_jual set jenis_paket='Wahana' where No_retur='RET004'
update retur_jual set jenis_paket='Lion' where No_retur='RET005'
update retur_jual set jenis_paket='Parsel' where No_retur='RET006'
update retur_jual set jenis_paket='Tiki' where No_retur='RET007'


No comments:

Post a Comment