1 / 12

Pemrograman Visual II Database Management System (DBMS)

Pemrograman Visual II Database Management System (DBMS). Oleh : Erna Sri Hartatik , S.Kom. POKOK BAHASAN. SELECT . . . CASE IF. CASE. Sering digunakan untuk menampilkan nilai tertentu dari beberapa barisan data dengan syarat-syarat atau kondisi yang telah berikan .

robyn
Download Presentation

Pemrograman Visual II Database Management System (DBMS)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pemrograman Visual IIDatabase Management System (DBMS) Oleh: Erna Sri Hartatik, S.Kom

  2. POKOK BAHASAN • SELECT . . . CASE • IF

  3. CASE • Seringdigunakanuntukmenampilkannilaitertentudaribeberapabarisan data dengansyarat-syaratataukondisi yang telahberikan. • perintahCASEdisisipkandalamperintahSELECT jadi yang dihasilkanlangsungberupaDATASETdanlangsungbisadilihathasilnya

  4. Perintah CASE ini mempunyai dua format • Simple Case function : CASE input_expressionWHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE result] END Fungsi CASE akanmengembalikanhasil/result tertentujika value = compare_value. Jikatidakadanilaihasil yang sesuai, akanmengembalikanhasilsetelah ELSE, atau NULL jikabagian ELSE tidakdidefinisikan.

  5. Searched CASE function: Maksudnyaperintah CASE inidiikutidengansyaratkondisiboolean, seperti >, <, >=, <= , dan lain-lain. CASE input_expressionWHEN Boolean_expression THEN compare_value[ ...n ][ELSE result] END

  6. CASE • EX: SELECT nama, CASE alamat WHEN 'PMK' THEN 'PAMEKASAN' WHEN 'SMP' THEN 'SAMPANG' ELSE alamat END AS kota_lahir FROM tbmhs • RESULT:

  7. CASE • Ex: SELECT tgl_lahir,CASE month(tgl_lahir) WHEN '01' THEN 'Januari' WHEN '02' THEN 'Pebruari' WHEN '03' THEN 'Maret' WHEN '04' THEN 'April' WHEN '05' THEN 'Mei' WHEN '06' THEN 'Juni' WHEN '07' THEN 'Juli' WHEN '08' THEN 'Agustus' WHEN '09' THEN 'September' WHEN '10' THEN 'Oktober' WHEN '11' THEN 'Nopember' ELSE 'Desember' END AS bulan from tbmhs • Result

  8. CASE • Ex: SELECT nim, ipk, CASE WHEN ipk >3.50 THEN 'Lulus Istimewa' WHEN ipk >2.75 THEN 'Lulus SangatMemuaskan' WHEN ipk >=2.00 THEN 'Lulus Memuaskan' END AS Kelulusan from tbipk • Result

  9. CASE • Ex: SELECT i.nim,m.nama, i.ipk, CASE WHEN i.ipk >3.50 THEN 'Lulus Istimewa' WHEN i.ipk >2.75 THEN 'Lulus Sangat Memuaskan' WHEN i.ipk >=2.00 THEN 'Lulus Memuaskan' END AS Kelulusan from tbipk i, tbmhs m WHERE i.nim = m.nim • Result

  10. IF • Fungsi If adalahsalahsatufungsiuntukmengetessuatukondisi. Jikakondisibernilaibenar (kondisi <> 0 dankondisi <> NULL), makafungsi IF akanmengembalikannilai_benar, jikatidakbenarmakaakanmengembalikannilai_salah. • Syntax: IF(Kondisi,nilai_benar,nilai_salah)

  11. IF • Ex: Select if(1<2,'Benar','Salah') as cek • Result

  12. IF • Ex: select nim, nama, if(alamat='pmk','pamekasan',if(alamat='smp','Sampang','Madura')) as alamat from tbmhs • Result

More Related