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