If you want make auto numbering (with or no case statement) on your query  (tested on MariaDB) i hope this article can help you. Very very simple..

Sample you dont want showing query liked this picture :


So if you look this result.. is no rapidly..

I want make result like this..

So.. first step you can make declare variable on your query with SET [VARIABLE] then your SELECT and your CASE.

SET [variable];
SELECT
[column]
CASE
WHEN [statement]
END
FROM [table]
[CONDITION]


So this my query for showing result with numbering and case statement.

SET @a := 0;
SELECT DISTINCT
(
CASE
WHEN a.form_sasaran <> '' THEN
@a :=@a + 1
ELSE
''
END
)
AS form_no_ukuran,
 a.form_sasaran,
 a.form_ukuran,
 a.form_bobot,
 a.form_hasil,
 a.form_catatan,
 b.temp_note,
(
CASE
WHEN a.form_total > 0 THEN
a.form_total
ELSE
''
END
)
AS form_total
FROM
mkpi_note AS b
RIGHT JOIN mkpi_form_nilai AS a ON b.temp_nik = a.kd_peg_sales
AND b.temp_periode = a.form_periode
AND b.temp_tahun = a.form_tahun
WHERE
a.form_nomor = 'M0000006'
AND a.form_tahun = 2018
AND a.form_periode = 1
AND a.kd_peg_sales = '00003'
AND a.form_tipe = 'mr'
ORDER BY
a.form_no_ukuran,
a.form_sasaran,
a.form_ukuran,
a.form_bobot,
a.form_hasil,
a.form_catatan,
b.temp_note,
a.form_total
ASC;



Post a Comment

Silahkan anda tulis komentar di bawah ini !

 
Top