//Syntax pembuatan table mahasiswa
create table pegawai
(tgl date,
kd_peg varchar2(10),
nama_peg varchar2(50),
alamat varchar2(50),
no_tlp varchar2(20),
constraint pk_pegawai primary key(kd_peg));
create table kehadiran
(tgl date,
jam_hadir varchar2(10),
jam_pulang varchar2(10),
id_kehadiran varchar2(10),
kd_peg varchar2(10),
nama_peg varchar2(50),
alamat varchar2(50),
no_tlp varchar2(20),
constraint pk_kehadiran primary key(id_kehadiran),
constraint fk_pegawai foreign key(kd_peg) references pegawai(kd_peg));
//Systax input data ke table pegawai
insert into pegawai values(TO_DATE('01-01-2013','DD-MM-YYYY'),'p-001','Arya','Jl. pulau adi','2020088');
insert into pegawai values(TO_DATE('01-01-2013','DD-MM-YYYY'),'p-002','Wayan','Jl. sudirman','0857375342257');
insert into pegawai values(TO_DATE('02-01-2013','DD-MM-YYYY'),'p-003','Budi','Jl. sesetan','081999675432');
insert into kehadiran values(TO_DATE('01-01-2013','DD-MM-YYYY'),'08:00','16:00','k-001','p-001','Arya','Jl. pulau adi','2020088');
insert into kehadiran values(TO_DATE('01-01-2013','DD-MM-YYYY'),'12:00','20:00','k-002','p-002','Wayan','Jl. sudirman','0857375342257');
insert into kehadiran values(TO_DATE('02-01-2013','DD-MM-YYYY'),'08:00','16:00','k-003','p-003','Budi','Jl. sesetan','081999675432');
insert into kehadiran values(TO_DATE('02-01-2013','DD-MM-YYYY'),'12:00','20:00','k-004','p-001','Arya','Jl. pulau adi','2020088');
insert into kehadiran values(TO_DATE('03-01-2013','DD-MM-YYYY'),'08:00','16:00','k-005','p-002','Wayan','Jl. sudirman','0857375342257');
insert into kehadiran values(TO_DATE('03-01-2013','DD-MM-YYYY'),'12:00','20:00','k-006','p-001','Arya','Jl. pulau adi','2020088');
insert into kehadiran values(TO_DATE('04-01-2013','DD-MM-YYYY'),'08:00','16:00','k-007','p-002','Wayan','Jl. sudirman','0857375342257');
insert into kehadiran values(TO_DATE('04-01-2013','DD-MM-YYYY'),'12:00','20:00','k-008','p-003','Budi','Jl. sesetan','081999675432');
insert into kehadiran values(TO_DATE('05-01-2013','DD-MM-YYYY'),'08:00','16:00','k-009','p-002','Wayan','Jl. sudirman','0857375342257');
//Syntax menampilkan data pada table barang berdasarkan kd_peg
select kehadiran.tgl, kehadiran.id_kehadiran, kehadiran.kd_peg, kehadiran.nama_peg, kehadiran.alamat from kehadiran order by kehadiran.kd_peg;
//Syntax menampilkan data pada table barang berdasarkan kd_peg
//Syntax menampilkan data jumlah kehadiran pegawai pada table pegawai yang didapat dari kd_peg
select kd_peg, count(kd_peg) as jumlah_kehadiran
from kehadiran
group by kd_peg
order by jumlah_kehadiran desc;
No comments:
Post a Comment