Left join with more than 2 tables

SELECT MDFT_RRAWAT.NM_RRAWAT, A.HITUNG
FROM MDFT_RRAWAT LEFT JOIN
(SELECT TDFT_RRAWAT_PASIEN.KD_RRAWAT , COUNT(*) AS HITUNG
FROM TDFT_RRAWAT_PASIEN, TDFT_KELUAR
WHERE TDFT_KELUAR.KD_CARAKELUAR=’02’
AND TDFT_KELUAR.TGL_KELUAR >= ‘2012-12-01’
AND TDFT_KELUAR.TGL_KELUAR <= ‘2012-12-31’
AND TDFT_RRAWAT_PASIEN.NO_PENDAFTARAN=TDFT_KELUAR.NO_PENDAFTARAN
GROUP BY TDFT_RRAWAT_PASIEN.KD_RRAWAT)
AS A ON MDFT_RRAWAT.KD_RRAWAT=A.KD_RRAWAT
ORDER BY MDFT_RRAWAT.KD_RRAWAT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: