Monday, May 22, 2017

Praktek 7 - Praktek Pemrograman SQL

Selasa, 23 Mei 2017

Haloo,, kali ini kita akan membuat tabel retur jual:

Tabel Penjualan

1. Isi data, ambil dari tabel penjualan, 2 record unutk diretur
    Membuat tabel:
    create table retur_jual(
    noretur varchar(10) primary key,
    Nonota varchar(10),
    tglretur date,
    jmlretur int,
    ketcacat varchar(50),
    foreign key(Nonota) references penjualan(Nonota))

    insert into retur_jual
    values
    ('R001','JUAL002','2017/03/19',5,'Kemasannya rusak'),
    ('R002','JUAL001','2017/03/21',3,'Kemasannya rusak')


3. Update stok barang
    update Barang set jumlah=150+50 where kdbrg='007'
    update Barang set jumlah=410+40 where kdbrg='008'

6. Tambahkan 5 data retur
    insert into retur_jual
   values
   ('R003','JUAL003','2017/04/18',10,'Kemasannya rusak'),
   ('R004','JUAL004','2017/05/01',3,'Kemasannya rusak'),
   ('R005','JUAL005','2017/05/07',5,'Kemasannya rusak'),
   ('R006','JUAL006','2017/05/19',5,'Kemasannya rusak'),
   ('R007','JUAL007','2017/06/11',7,'Kemasannya rusak')

7. Update data 3 retur
    update retur_jual set jmlretur=10 where noretur='R001'
    update retur_jual set jmlretur=5 where noretur='R006'
    update retur_jual set jmlretur=5 where noretur='R007'

8. Delete record 1 data retur
    delete from retur_jual where noretur='R007'

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 noretur='R001'
     update retur_jual set jenis_paket='JNE' where noretur='R002'
     update retur_jual set jenis_paket='JNE' where noretur='R003'
     update retur_jual set jenis_paket='JNE' where noretur='R004'
     update retur_jual set jenis_paket='JNE' where noretur='R005'
     update retur_jual set jenis_paket='JNE' where noretur='R006'

No comments:

Post a Comment