1.Kamu Punya tabel `pelanggan` Dengan beberapa kolom : `nama`, `alamat`, `telepon`. bagaimana cara memilih ,hanya nama dan alamat di tabel `pelanggan`?
JAWABAN:
`SELECT nama, alamat FROM pelanggan;`
2.Kamu Punya tabel :`nama`, `harga`. Bagaimana cara kamu buat memilih semua produk di baris dengan tulisan yang ada A nya di Produk
JAWABAN:
`SELECT * FROM produk WHERE nama LIKE ‘%A%’;`
3.Kamu Punya tabel `transaksi` with a few columns: `id_transaksi`, `total`. How are you going to select all the transaksi where the total is more than 1000?
Question: You have a table `pelanggan` with a few columns: `nama`, `alamat`, `telepon`. How are you going to select all the pelanggan where the name starts with the letter ‘A’ and addresses start with ‘J’?
Answer: `SELECT * FROM pelanggan WHERE nama LIKE ‘A%’ AND alamat LIKE ‘J%’;`
Question: You have a table `produk` with a few columns: `nama`, `harga`. How are you going to select all the produk where the price of the produk is more than 500 or the name of the produk’s produk contains the letter ‘B’?
Answer: `SELECT * FROM produk WHERE harga > 500 OR nma LIKE ‘%B%’;`
Question: You have a table `transaksi` with a few columns: `id_transaksi`, `total`. How are you going to select all the transaksi where the total number is between 500 and 1500?
Answer: `SELECT * FROM transaksi WHERE total BETWEEN 500 AND 1500;`
Question: You have a table `produk` with a few columns: `nama`, `harga`. How are you going to select the average price of produk?
Answer: `SELECT AVG(harga) AS average_price FROM produk;`
Question: You have a table `transaksi` with a few columns: `id_transaksi`, `total`. How are you going to select the sum of transaksi?
Answer: `SELECT SUM(total) AS sum_of_transaksi FROM transaksi;`
Question 9: Count
Question: You have a table `pelanggan` with a few columns: `nama`, `alamat`, `telepon`. How are you going to select the count of pelanggan?
Answer: `SELECT COUNT(*) AS count_of_pelanggan FROM pelanggan;`
10: Combination of Operations
Question: You have a table `produk` with a few columns: `nama`, `harga`. How are you going to select all the produk where the price of the produk is more than 500 and the name of the produk’s produk contains the letter ‘B”?
Answer: `SELECT * FROM produk WHERE harga > 500 AND nama LIKE ‘%B%’;`
Tidak ada komentar:
Posting Komentar