0

My database table is

id kecamatan tanggal
1 AA 02-01-2022
2 AB 03-01-2022
3 AA 10-01-2022
4 AB 12-01-2022
5 AA 17-01-2022
6 AC 18-01-2022

I want this result, because I can not replace other structure

id kecamatan 202202 202203 202204
1 AA 02-01-2022 10-01-2022 17-01-2022
2 AB 03-01-2022 12-01-2022
3 AC 18-01-2022

FAQ : 202202,202203,202204 is grouping query by week

Vickel
  • 7,879
  • 6
  • 35
  • 56
  • what is the logic behind your desired output? 1st I thought 202201 is the 1st *tanggal*, etc. but AC's 1st is in *202203*, why? can you please edit your question to make this more clear? ohhh... calendar week? – Vickel Jan 21 '22 at 01:46
  • 202201,202202,202203 is grouping query by week.. Tanks vickel – Dimas Cornellya Agatta Jan 21 '22 at 01:57
  • please have a look into mysql WEEK function: https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_week. translate the dates into a week number and query from there and: https://stackoverflow.com/a/6710398/2275490 – Vickel Jan 21 '22 at 02:11

0 Answers0