Tolong pilih kategori sesuai, jenis posting (pertanyaan atau bukan) dan sertakan tag/topik yang sesuai misal komputer, php, mysql, dll.
Promosi atau posting tidak pada tempatnya akan kami hapus.
Mencantumkan kode program di posting Anda, tolong ikuti aturan yang sesuai, baca http://diskusiweb.com/discussion/39204/aturan-cara-menyisipkan-kode-program-di-diskusiweb

Baca cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

Tanya Query Menampilkan beberapa table nilai terakhir

Permisi Para master , mau tanya perintah query memilih tabel dengan isian terakhir.. terima kasih sebelumnya

berikut tabelnya master https://s27.postimg.org/o4ma1ac1v/query.png

Tanggapan

  • edited January 27
    @agusslamet Untuk tabel mahasiswa jadi tidak berfungsi apabila masih menggunakan nama (Redundancy).
    Hemm... kyknya harus 1-1 di kerjain-nya, sy kurang tau untuk cara terbaik/tercepat.
    //Klarifikasi :
    //Tabel NIS = mhs,
    //Tabel Riwayat Ujian Tulis = ujian_tulis
    //Tabel Riwayat Ujian Lisan = ujian_lisan
     
    // SELECT DATA FROM UJIAN_TULIS WHERE no_ujian paling akhir
    SELECT m1.nama, (m1.no_ujian) AS ujian_tulis, (m1.nilai) AS nilai_tulis
    FROM ujian_tulis m1 LEFT JOIN ujian_tulis m2
    ON (m1.nama = m2.nama AND m1.no < m2.no)
    WHERE m2.no IS NULL
     
    // SELECT DATA FROM UJIAN_LISAN WHERE no_ujian paling akhir
    SELECT m3.nama, (m3.no_ujian) AS ujian_lisan, (m3.nilai) AS nilai_lisan
    FROM ujian_lisan m3 LEFT JOIN ujian_lisan m4
    ON (m3.nama = m4.nama AND m3.no < m4.no)
    WHERE m4.no IS NULL
     
    // JOIN 2 SQL + ADD No
    SELECT @n := @n + 1 No, x.nama, x.ujian_tulis, x.nilai_tulis, y.ujian_lisan, y.nilai_lisan
    FROM ( SELECT m1.nama, (m1.no_ujian) AS ujian_tulis, (m1.nilai) AS nilai_tulis
    FROM ujian_tulis m1 LEFT JOIN ujian_tulis m2
    ON (m1.nama = m2.nama AND m1.no < m2.no)
    WHERE m2.no IS NULL ) AS x
    JOIN
    ( SELECT m3.nama, (m3.no_ujian) AS ujian_lisan, (m3.nilai) AS nilai_lisan
    FROM ujian_lisan m3 LEFT JOIN ujian_lisan m4
    ON (m3.nama = m4.nama AND m3.no < m4.no)
    WHERE m4.no IS NULL ) AS y ON x.nama = y.nama, (SELECT @n := 0) m;

    Online Check SQL : http://sqlfiddle.com/#!9/fb443/1
  • Pada Sql Server 2000

    SELECT dbo.data_mahasiswa.nis, dbo.data_mahasiswa.nama, MAX(dbo.data_ujian_tulis.ujian_ke) AS ujian_tulisan_ke,
    MAX(DISTINCT dbo.data_ujian_tulis.nilai_ujian_tulis) AS nilai_tulis, MAX(dbo.data_ujian_lisan.ujian_ke) AS ujian_lisan_ke,
    MAX(DISTINCT dbo.data_ujian_lisan.nilai_ujian_lisan) AS nilai_lisan
    FROM dbo.data_mahasiswa INNER JOIN
    dbo.data_ujian_tulis ON dbo.data_mahasiswa.nis = dbo.data_ujian_tulis.nis INNER JOIN
    dbo.data_ujian_lisan ON dbo.data_mahasiswa.nis = dbo.data_ujian_lisan.nis
    GROUP BY dbo.data_mahasiswa.nis, dbo.data_mahasiswa.nama

  • Gan beli raket nyamuk
Sign In or Register to comment.