Monday, May 22, 2017

PRAKTEK PEMOGRAMAN SQL


create table retur(

Noretur varchar(10) primary key,

Nonota varchar(10),

tanggalretur date,

jumlahretur int,

keterangancacat varchar(50),

foreign key (Nonota) references penjualan)



1.       Isi data,diambil dari tabel penjualan, 2 record untuk di retur

insert into retur values ('R001','JUAL001','2017/03/21',2,'Kadarluwarsa')

insert into retur values ('R002','JUAL002','2017/03/30',5,'Bungkus Barang Rusak')



2.       Browsing operasi matematika menggunakan SQL untuk penambahan stock barang

3.       Alternative lain, update stock barang

update barang set harga=3000 where kdbrg='001'

update barang set jumlah=90 where kdbrg='002'

update barang set harga=8000 where kdbrg='003'

update barang set jumlah=250 where kdbrg='004'

update barang set jumlah=200 where kdbrg='005'

update barang set jumlah=40 where kdbrg='006'

update barang set jumlah=50 where kdbrg='007'

update barang set jumlah=25 where kdbrg='008'

update barang set jumlah=100 where kdbrg='009'

update barang set jumlah=150 where kdbrg='010'

4.       Jumlah retur tidak melebihi jumlah jual



5.       Tanggal retur tidak boleh sebelum tanggal jual


6.       Tambahkan 5 data retur

insert into retur values ('R003','JUAL003','2017/04/10',3,'kadarluarsa')

insert into retur values ('R004','JUAL004','2017/05/02',10,'kadarluarsa')

insert into retur values ('R005','JUAL005','2017/05/13',11,'kemasan luar rusak')

insert into retur values ('R006','JUAL006','2017/05/31',25,'kadarluarsa dan kemasan luar rusak')

insert into retur values ('R007','JUAL007','2017/06/17',25,'kadarluarsa dan rusak')


7.       Update data 3 retur

update retur set jumlahretur='4' where Noretur='R003'

update retur set jumlahretur=5 where Noretur='R004'

update retur set jumlahretur=10 where Noretur='R007'


8.       Delete record 1 data retur

delete from retur where Noretur='R007'



9.       Tambahkan field jenis_paket
alter table retur add jenis_paket varchar(20)



10.   Isi jenis paket
update retur set jenis_paket='JNA' where Noretur='R001'

update retur set jenis_paket='POS' where Noretur='R002'

update retur set jenis_paket='J&T'where Noretur='R003'

update retur set jenis_paket='TIKI' where Noretur='R004'

update retur set jenis_paket='JNA' where Noretur='R005'

update retur set jenis_paket='TIKI'where Noretur='R006'




No comments:

Post a Comment