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

S4M 2022432105 JoeRomelPutraAgatha

The document contains SQL queries and statements. It creates tables, inserts data, performs selects with filters, joins, aggregation, and alters tables. It also contains a query to get the current date, day of week and time.

Uploaded by

ririnfujianty6
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)
38 views2 pages

S4M 2022432105 JoeRomelPutraAgatha

The document contains SQL queries and statements. It creates tables, inserts data, performs selects with filters, joins, aggregation, and alters tables. It also contains a query to get the current date, day of week and time.

Uploaded by

ririnfujianty6
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

Nama : Joe Romel Putra Agatha

Kelas : S4M

NPM : 202243502105

1. USE Joe_Romel_105;

CREATE TABLE Mahasiswa (


ID INT AUTO_INCREMENT PRIMARY KEY,
Nama VARCHAR(255),
Nomor_Npm INT

);

2. CREATE TABLE Murid (


id_student VARCHAR(10) PRIMARY KEY,
Nama_student VARCHAR(255),
Usia INT

);

INSERT INTO Student (id_student, Nama_student, Usia) VALUES

('ST21', 'Amar', 16),

('ST22', 'Fandy', 17),

('ST23', 'Zaky', 16),

('ST24', 'Madina', 15);

3. SELECT Nama_student, Usia


FROM Student
ORDER BY Usia DESC;

4. SELECT kd_course, tgl_mulai_course, tgl_akhir_course, biaya


FROM course
WHERE MONTH(tgl_akhir_course) = 7;

5. SELECT id_student, kd_course, biaya


FROM course
WHERE id_student = 'ST23';
6. SELECT *
FROM Student s
WHERE EXISTS (
SELECT 1
FROM course c
WHERE c.id_student = s.id_student
);

7. SELECT *
FROM course
WHERE biaya = (
SELECT MAX(biaya)
FROM course
);

8. SELECT kd_course, SUM(biaya) AS total_biaya


FROM course
GROUP BY kd_course;

9. Menambahkan kolom alamat ke tabel student:


ALTER TABLE Student
ADD COLUMN Alamat VARCHAR(255);

Mengubah isi alamat untuk salah satu mahasiswa (misalnya id_student ST21):
UPDATE Student
SET Alamat = 'Jl. Kayu ringin No. 12, Kota Bekasi'
WHERE id_student = 'ST21';

10. SELECT DAYOFWEEK(NOW()) AS Hari,


DATE(NOW()) AS Tanggal,
TIME(NOW()) AS Waktu;

You might also like