Buat kolom waktu baru tanpa menggunakan fungsi MAX / SUM

Saya ingin merubah format table untuk keperluan view di web application.

Berikut tabel yang saya punya :

1.PNG

Saya ingin menjadi seperti ini :

2.PNG

avatar rifkitr_google
@rifkitr_google

2 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

2 Jawaban:

<div>Sepertinya ini bukan untuk keperluan nyata ya.<br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;sk_rifkitr_google__pivot.png&quot;,&quot;filesize&quot;:28860,&quot;height&quot;:839,&quot;url&quot;:&quot;https://i.ibb.co/qxq0DFG/sk-rifkitr-google-pivot.png&quot;,&quot;width&quot;:782}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/qxq0DFG/sk-rifkitr-google-pivot.png" width="782" height="839"><figcaption class="attachment__caption"><span class="attachment__name">sk_rifkitr_google__pivot.png</span></figcaption></figure><br>Sorry soal bukan untuk keperluan nyata; dengan melimit penggunaan window-function akan berdampak pada cost-query-nya.<br>update query-nya, ada kemungkinan data NULL-nya itu NULL bukan string "NULL"<br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;sk_rifkitr_google__pivot_query.png&quot;,&quot;filesize&quot;:377930,&quot;height&quot;:2388,&quot;url&quot;:&quot;https://i.ibb.co/FzBj6g9/sk-rifkitr-google-pivot-query.png&quot;,&quot;width&quot;:1294}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/FzBj6g9/sk-rifkitr-google-pivot-query.png" width="1294" height="2388"><figcaption class="attachment__caption"><span class="attachment__name">sk_rifkitr_google__pivot_query.png</span></figcaption></figure><br><br>Coba lihat hasil test di <a href="http://sqlfiddle.com/#!9/b1316a/5">SQLFiddler</a>.<br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;sk_rifkitr_google__pivot_query_2.png&quot;,&quot;filesize&quot;:490631,&quot;height&quot;:2308,&quot;url&quot;:&quot;https://i.ibb.co/tbkHfrB/sk-rifkitr-google-pivot-query-2.png&quot;,&quot;width&quot;:1134}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/tbkHfrB/sk-rifkitr-google-pivot-query-2.png" width="1134" height="2308"><figcaption class="attachment__caption"><span class="attachment__name">sk_rifkitr_google__pivot_query_2.png</span></figcaption></figure><br><br></div>

avatar soeleman
@soeleman

120 Kontribusi 147 Poin

Dipost 4 tahun yang lalu

Tanggapan

Di saya masih salah urutannya gan, agan pake SQL Server ya? sy pke MySQL di Phpmyadmin

Untuk test ini pakai MySQL 8.

<div>ini untuk keperluan nyata Pak @soeleman<br>dr kmrn saya sdh query sesuai denga itu tp hasilnya agak beda dari urutannya<br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image.png&quot;,&quot;filesize&quot;:15955,&quot;height&quot;:349,&quot;url&quot;:&quot;https://i.ibb.co/F5g1hGy/image.png&quot;,&quot;width&quot;:241}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/F5g1hGy/image.png" width="241" height="349"><figcaption class="attachment__caption"><span class="attachment__name">image.png</span></figcaption></figure></div>

avatar rifkitr_google
@rifkitr_google

2 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Tanggapan

update jawaban diatas

Login untuk ikut Jawaban