SELECT
	b.nama_nakes AS nama_dokter,
	poli,
	CONCAT( COUNT( b.nama_nakes ),   pemeriksaan  ) AS jumlah_pemeriksaan 
FROM
	(
SELECT
	id_dokter,
	tanggal,
	 Poli Umum  AS poli 
FROM
	medis_rawat_jalan_umum 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m ) UNION ALL
SELECT
	id_dokter,
	tanggal,
	 Poli THT  AS poli 
FROM
	medis_rawat_jalan_tht 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m ) UNION ALL
SELECT
	id_dokter,
	tanggal,
	 Poli Bedah  AS poli 
FROM
	medis_bedah 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m ) UNION ALL
SELECT
	id_dokter,
	tanggal,
	 Poli Penyakit Dalam  AS poli 
FROM
	medis_penyakit_dalam 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m ) UNION ALL
SELECT
	id_dokter,
	tanggal,
	 Poli Anak  AS poli 
FROM
	medis_rawat_jalan_anak 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m ) UNION ALL
SELECT
	id_dokter,
	tanggal,
	 Poli Kandungan  AS poli 
FROM
	medis_rawat_jalan_obgyn 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m ) UNION ALL
SELECT
	id_dokter,
	tanggal,
	 Poli Gigi  AS poli 
FROM
	pemeriksaan_gigi 
WHERE
	MONTH(tanggal) = DATE_FORMAT(CURRENT_DATE(), %m )
		) a
	JOIN medis_tenaga b ON a.id_dokter = b.kode_nakes 
GROUP BY
	b.nama_nakes 
ORDER BY
	COUNT( b.nama_nakes ) DESC