You are on page 1of 11

Nama : I Komang Mandala Putra

NIM 200030254
Kelas : Praktikum Basis Data (BA213)

2. a. select AVG(total_payment)as [Rata Bayar]


from tr_payment

b. select MAX(regist_id), MAX(total_payment)


from tr_payment

c.select COUNT(*) as banyaknya_pembayaran


from tr_payment
where Total_payment > 1500000
d. select count(distinct Room) AS Jumlah_ruangan
from tr_jadwal
where Day_ between 'mon' and 'tue'

e. select COUNT(total_payment) As Jumlah_Payment, SUM(total_payment) as


Total_Payment
from tr_payment
f. select MIN(total_payment) as min_payment,
MAX(total_payment) as max_Payment,
avg(total_payment) as avg_payment
from tr_payment

3. a. select program_id, COUNT(program_id) as myCount


from tr_jadwal
group by program_id
b.select student_gender, COUNT(student_id) as myCount
from ms_student
group by student_gender

c.select tutor_id, COUNT(tutor_id) as myCount


from tr_jadwal
group by tutor_id
d. select tutor_id, room,COUNT(tutor_id) as myCount
from tr_jadwal
group by tutor_id, Room

4. a. select program_id, COUNT(jadwal_id) as banyaknya_jadwal


from tr_jadwal
group by Program_id
having COUNT (Jadwal_id) > 1
b. select program_id, written_test, COUNT(program_id) as jml_siswa
from tr_result
group by program_id, Written_Test
order by program_id, Written_Test

select program_id, written_test,COUNT(program_id) as jml_siswa


from tr_result
group by program_id, Written_Test
having COUNT(program_id) > 1
order by program_id, Written_Test
5. a. select student_id
from ms_student
where Student_id IS NOT NULL
union
select student_id
from tr_regist
where Student_id IS NOT NULL

b. select student_id
from tr_result
where Note = 'GOOD'
union
select student_id
from tr_regist
where grade_id = 'B'

c. select student_id, student_address, student_gender


from ms_student
where student_gender = 'Male'
union
select tutor_id, tutor_address, tutor_gender
from ms_tutor
where Tutor_gender = 'Male'

6.a. select jadwal_id, tutor_id


from tr_jadwal
where program_id =
(select program_id
from ms_program
where Program_id = 'pc001')

b.select payment_id, total_payment, payment_date


from tr_payment
where Total_payment >
(select AVG(Total_payment) from tr_payment)

c. select student_id, student_name


from ms_student
where Student_id in(select Student_id
from trd_absensi
where Pertemuan_5 = 'hadir')

d. select *
from tr_payment
where Total_payment > all(select Total_payment
from tr_payment
where regist_id in ('reg001', 'reg003', 'reg009'))

e.select *
from tr_payment
where Total_payment > any(select Total_payment
from tr_payment
where regist_id in ('reg001', 'reg003', 'reg009'))

You might also like