SQL SCRIPT (MYSQL)
Sumber:https://www.nomor.net
Update per 18 Mei 2023:
38 propinsi, 514 kota+kabupaten, 7.277 kecamatan/distrik, 83.763 desa/kelurahan.
Contoh Verifikasi
Jumlah Propinsi
SELECT COUNT(*) AS `Total Propinsi`
FROM (SELECT kodewilayah
FROM kodewilayah2023
GROUP BY namapropinsi) AS kodewilayah
Jumlah Kabupaten
SELECT COUNT(*) AS `Total Kabupaten`
FROM (SELECT kodewilayah FROM kodewilayah2023
WHERE kodekabkota='Kabupaten'
GROUP BY LEFT(kodewilayah,5)) AS kodewilayah
Jumlah Kota
SELECT COUNT(*) AS `Total Kota`
FROM (SELECT kodewilayah FROM kodewilayah2023
WHERE kodekabkota='Kota'
GROUP BY LEFT(kodewilayah,5)) AS kodewilayah
Jumlah Kota+Kabupaten
SELECT COUNT(*) AS `Total Kota+Kabupaten`
FROM (SELECT kodewilayah FROM kodewilayah2023
GROUP BY LEFT(kodewilayah,5)) AS kodewilayah
Jumlah Kecamatan
SELECT COUNT(*) AS `Total Kecamatan`
FROM (SELECT kodewilayah FROM kodewilayah2023
GROUP BY LEFT(kodewilayah,8)) AS kodewilayah
Jumlah Desa/Kelurahan
SELECT COUNT(*) AS `Total Desa/Kelurahan`
FROM kodewilayah2023
Contoh Rekap:
SELECT (SELECT COUNT(*)
FROM (SELECT NULL
FROM kodewilayah2023
GROUP BY namapropinsi) Propinsi) AS 'Total Propinsi',
(SELECT COUNT(*)
FROM (SELECT NULL
FROM kodewilayah2023
GROUP BY LEFT(kodewilayah,5)) KotaKabupaten) AS `Total Kota+Kabupaten`,
(SELECT COUNT(*)
FROM (SELECT NULL
FROM kodewilayah2023
GROUP BY LEFT(kodewilayah,8)) Kecamatan) AS `Total Kecamatan`,
(SELECT COUNT(*)
FROM kodewilayah2023) AS `Total Desa/Kelurahan`