答案 0 :(得分:0)
如果您的意思是2
行,请使用
select * from table_name where baris = 2;
如果您只想获取第二行
select * from table_name LIMIT 1, 1;
如果您想使用ORDER BY
子句,也可以使用它(仅当您正在寻找2nd largest or 2nd smallest
时才这样做。)
答案 1 :(得分:0)
这是我的查询
SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai
ON nilai.id_data_nilai = data_nilai.idx
WHERE data_nilai.id_tahun_ajar = '1'
AND data_nilai.id_sekolah = '1040902040'
AND data_nilai.id_kelas = '2'
AND data_nilai.id_rombel = '2'
AND data_nilai.id_mapel = '13'
AND data_nilai.status_nilai = '0'
AND data_nilai.id_jn = '1'
AND nilai.user_id = 'IDS0000707'
UNION
SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai
ON nilai.id_data_nilai = data_nilai.idx
WHERE data_nilai.id_tahun_ajar = '1'
AND data_nilai.id_sekolah = '1040902040'
AND data_nilai.id_kelas = '2'
AND data_nilai.id_rombel = '2'
AND data_nilai.id_mapel = '13'
AND data_nilai.status_nilai = '0'
AND data_nilai.id_jn = '2'
AND nilai.user_id = 'IDS0000707'
UNION
SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai
ON nilai.id_data_nilai = data_nilai.idx
WHERE data_nilai.id_tahun_ajar = '1'
AND data_nilai.id_sekolah = '1040902040'
AND data_nilai.id_kelas = '2'
AND data_nilai.id_rombel = '2'
AND data_nilai.id_mapel = '13'
AND data_nilai.status_nilai = '0'
AND data_nilai.id_jn = '3'
AND nilai.user_id = 'IDS0000707'
UNION
SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai
ON nilai.id_data_nilai = data_nilai.idx
WHERE data_nilai.id_tahun_ajar = '1'
AND data_nilai.id_sekolah = '1040902040'
AND data_nilai.id_kelas = '2'
AND data_nilai.id_rombel = '2'
AND data_nilai.id_mapel = '13'
AND data_nilai.status_nilai = '0'
AND data_nilai.id_jn = '8'
AND nilai.user_id = 'IDS0000707'