Basis Data Tugas SQL
Basis Data Tugas SQL
Basis Data Tugas SQL
Kelas :E
Nim : 2350081143
Tugas basis data SQL
Jawaban
1. Membuat tabel Student
CREATE TABLE students (
student_id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
major VARCHAR(50),
enrollment_year INT CHECK (enrollment_year >= 2000)
);
ROLLBACK;
10. Menampilkan Jumlah Peminjaman untuk Setiap Mahasiswa, Urut Berdasarkan
Jumlah Peminjaman
SELECT s.name AS student_name, COUNT(br.record_id) AS
borrow_count
FROM borrow_records br
JOIN students s ON br.student_id = s.student_id
GROUP BY s.student_id, s.name
ORDER BY borrow_count DESC;