Arsip: Tanya SQL

 
user image
more 15 years ago

irmains

Tiba-tiba merasaa stuck n gak mudeng, mw tanya ya... Ada 2 tabel -Tabel1- idHasil|Nilai 81 100 82 80 83 99 84 89 -Tabel2- idKriteria|Nilai 81 9 82 8 83 10 84 7 85 9 86 7 87 6 88 8 89 9 90 7 Yang mw ditanyakan, gmana ya caranya untuk menampilkan id yang ada di tabel2 tapi gak ada di tabel1, sehingga hasilnya nanti kaya gini idKriteria|Nilai 85 9 86 7 87 6 88 8 89 9 90 7 Tiba-tiba merasa sulit bgt... Matur nuwun sanget nggih Kakak-Kakak...
user image
more 15 years ago

irmains

Maaf Maaf,, gak jadi tanya kakak, udah bisa \(^_^)/ Ternyata cuma s elect * from table2   w here idKriteria not in (s elect idHasil from table1); Matur nuwun sanget nggih Kakak-Kakak...
user image
more 15 years ago

elva_ivana

:?: :?: :?:
user image
more 15 years ago

Manz

Nah, dilanjut [code:1:fa51bf8b99] Tabel karyawan: NIP | Nama ------------------------ 001 | Udin tea 002 | Budi Kahandap 003 | Andi Kararangge 004 | Cecep Gorbacep 005 | Ono Ontohod Tabel master_absen: tipe_absen | deskripsi ---------------------- AL | ALPA SK | SAKIT CT | CUTI Tabel absen: NIP | TGL | tipe_absen ------------------------------ 001 | 01/07/2009 | AL 001 | 02/07/2009 | AL 002 | 05/07/2009 | CT 004 | 05/07/2009 | CT 002 | 06/07/2009 | SK 003 | 07/07/2009 | SK 003 | 08/07/2009 | SK 003 | 09/07/2009 | SK 003 | 10/07/2009 | SK 005 | 11/07/2009 | AL 005 | 12/07/2009 | AL 005 | 13/07/2009 | AL 005 | 14/07/2009 | AL [/code:1:fa51bf8b99] Hasil yang di-ingin-kan: [code:1:fa51bf8b99] NIP | NAMA | AL | CT | SK ------------------------------------ 001 | Udin tea | 2 | 0 | 0 002 | Budi Kahandap | 0 | 1 | 0 003 | Andi Kararangge | 0 | 0 | 4 004 | Cecep Gorbacep | 0 | 1 | 0 005 | Ono Ontohod | 4 | 0 | 0 [/code:1:fa51bf8b99] Tapi kalau data master_absen ditambah menjadi : [code:1:fa51bf8b99] tipe_absen | deskripsi -------------------------- AL | ALPA SK | SAKIT CT | CUTI IZ | IZIN PULANG kemudian data absen jadi : NIP | TGL | tipe_absen ------------------------------ 001 | 01/07/2009 | AL 001 | 02/07/2009 | AL 002 | 05/07/2009 | CT 004 | 05/07/2009 | CT 002 | 06/07/2009 | SK 003 | 07/07/2009 | SK 003 | 08/07/2009 | SK 003 | 09/07/2009 | SK 003 | 10/07/2009 | SK 005 | 11/07/2009 | AL 005 | 12/07/2009 | AL 005 | 13/07/2009 | AL 005 | 14/07/2009 | AL 003 | 20/07/2009 | IZ 004 | 21/07/2009 | IZ [/code:1:fa51bf8b99] hasilnya pengen jadi : [code:1:fa51bf8b99] NIP | NAMA | AL | CT | SK | IZ ----------------------------------------- 001 | Udin tea | 2 | 0 | 0 | 0 002 | Budi Kahandap | 0 | 1 | 0 | 0 003 | Andi Kararangge | 0 | 0 | 4 | 1 004 | Cecep Gorbacep | 0 | 1 | 0 | 1 005 | Ono Ontohod | 4 | 0 | 0 | 0 [/code:1:fa51bf8b99] Nah, pertanyaannya : Gimana caranya pengen pake single SQL Statements :?: :twisted: :twisted: tanpa pake luping lupingan nu lieur on tohod ... :mrgreen: Hatur Tengkiu ... Man'z tea geuningan :mrgreen:
user image
more 15 years ago

muktaf

itu namanya row to column ... coba pake if atau case di sql untuk bikin row to column..
user image
more 15 years ago

Manz

@muktaf ... we need the code ... not the statement only ... hehehehehehe :mrgreen:
user image
more 15 years ago

muktaf

select sum(IF(tipe_absen='AL')) as AL,sum(IF(tipe_absen='CT')) as CT,sum(IF(tipe_absen='SK')) as SK,sum(IF(tipe_absen='IZ')) as IZ form namatable group by nip Mudah mudahan membantu
user image
more 15 years ago

nurez

"dijoinin" aja hatuh kangg... tp aq jg blom terfikirkan untuk mencobanya... hehehe...maff... :)
user image
more 15 years ago

elva_ivana

kang Manz coba di http://tampanteddy.blogspot.com/2009/06/tanya-sql.html
user image
more 15 years ago

sikuper85

hhmmn, yg diharapkan kang Manz tu bukan hal yg simpel (sesimpel itu klo kata kang Manz-nya mah, kali). (abis liat2 blog-nya kang Manz, widiw serem banged). yg diharapkan kang Manz, sepertinya, satu statement sql (oriented bgt sama yg 1 ini yawh), yg bisa menghasilkan dataset dengan jumlah kolom yg dinamis sesuai dengan isi data dari tabel tertentu. (memungkinkan ga yawh... [untuk saat ini maksudnya]) klo yg standar seperti yg diatas (ga dinamis), ga pake view juga bisa deh kayanya, tinggal pake kode yg mirip dari pak muktaf. [sql] ... Sum(IIf(tipe_absen='AL',1,0)) AS AL, Sum(IIf(tipe_absen='CT',1,0)) AS CT, Sum(IIf(tipe_absen='SK',1,0)) AS SK, ... [/sql] lho kok elipsis, (hemat energi... ^_^) CMIIW.
more ...
  • Pages:
  • 1
  • 2
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com