Created
May 8, 2019 02:08
-
-
Save fahmiegerton/c4d37b53c8046e733ecbd527be240379 to your computer and use it in GitHub Desktop.
Relasi tabel apotek
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--merelasikan table kasir dengan tabel penyakit | |
-- Kasir => transaksi => obat => penyakit | |
--Merelasikan semua tabel | |
select * from kasir inner join transaksi on transaksi.idkasir=kasir.idkasir | |
inner join obat on obat.idobat=transaksi.idobat | |
inner join penyakit on penyakit.idpenyakit=obat.idpenyakit | |
inner join pelanggan on pelanggan.idpel=transaksi.idpel | |
inner join jenis on jenis.idjenis = obat.idjenis; | |
--relasikan tabel pelanggan dan tabel obat | |
select * from pelanggan | |
inner join transaksi on transaksi.idpel = pelanggan.idpel | |
inner join obat on obat.idobat = transaksi.idobat; | |
--relasikan tabel obat dengan tabel jenis | |
select * from jenis inner join obat on obat.idjenis = jenis.idjenis; | |
--menampilkan jumlah qty obat | |
select transaksi.idobat, obat.namaobat, sum(transaksi.qty) from transaksi inner join obat on obat.idobat = transaksi.idobat | |
where transaksi.idobat = 'OB002' | |
group by transaksi.idobat, obat.namaobat; | |
--menampilkan jumlah pelanggan yang dilayani oleh masing-masing kasir | |
select transaksi.idkasir, kasir.namakasir, kasir.shift, count(transaksi.idpel) from transaksi | |
inner join kasir on kasir.idkasir = transaksi.idkasir | |
group by transaksi.idkasir, kasir.namakasir, kasir.shift | |
order by transaksi.idkasir asc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment