0% found this document useful (0 votes)
39 views2 pages

PBD M11 PreTest Sli - Do Soal Only

The document contains 7 questions about SQL queries involving operations like SELECT, UNION, EXCEPT, INTERSECT on multiple tables to retrieve and compare data. The queries select data from tables like Employees, Department, Pegawai, Pengarang, Produk, Rating, PenjualanGrosir, and PenjualanEcer and perform calculations like averages and comparisons on columns like EmpNo, DeptName, NamaPegawai, NamaPengarang, id, nama, user, id_produk, nilai, NoFaktur, Tgl, KodePel, Total, and NoBon.

Uploaded by

Jagoan Bunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

PBD M11 PreTest Sli - Do Soal Only

The document contains 7 questions about SQL queries involving operations like SELECT, UNION, EXCEPT, INTERSECT on multiple tables to retrieve and compare data. The queries select data from tables like Employees, Department, Pegawai, Pengarang, Produk, Rating, PenjualanGrosir, and PenjualanEcer and perform calculations like averages and comparisons on columns like EmpNo, DeptName, NamaPegawai, NamaPengarang, id, nama, user, id_produk, nilai, NoFaktur, Tgl, KodePel, Total, and NoBon.

Uploaded by

Jagoan Bunda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Pretest (Sli.

do)

1. Soal 1

SELECT EmpNo as Kolom1, LastName as Kolom2 FROM Employees

UNION

SELECT DeptNo, DeptName FROM Department WHERE DeptName LIKE '%e'

ORDER BY DeptName

2. Soal 2

SELECT NamaPegawai FROM Pegawai WHERE NamaPegawai like '%a%'

EXCEPT

SELECT NamaPengarang FROM Pengarang

3. Soal 3

SELECT NamaPengarang FROM Pengarang

INTERSECT

SELECT NamaPegawai FROM Pegawai

4. Soal 4
Diketahui struktur dari:
Tabel Rating (id, user, id_produk, nilai)
Tabel Produk (id, nama)

Query berikut bertujuan untuk menambil rata-rata nilai rating dari id produk = 1:
SELECT AVG(nilai) FROM
(SELECT T1.id, T1.Nama, T2.nilai from Produk as T1 INNER JOIN
Rating as T2 ON T1.id = T2.id_produk where T1.id = 1) Temp
5. Soal 5
Diketahui struktur dari:
Tabel Rating (id, user, id_produk, nilai)
Tabel Produk (id, nama)

Query:
SELECT * from Produk where id =
(SELECT * from Rating where nilai > 3)

6. Soal 6
Diketahui struktur tabel berikut:
PenjualanGrosir (NoFaktur varchar(10), Tgl DateTime, KodePel varchar(10), Total Int)
PenjualanEcer (NoBon varchar(10), Tgl DateTime, Total Int)

Query:
SELECT NoBon, Tgl, Total FROM PenjualanEcer WHERE Total < 1000000
UNION ALL
SELECT NoFaktur, Tgl, KodePel FROM PenjualanGrosir WHERE Total > 1000000
ORDER BY NoFaktur

7. Soal 7

You might also like