Senin, 22 Juli 2013

Query untuk ngecek/melihat perkara CG sudah putus belum keluar ac

SELECT A.NO_PERK,A.TGL_PUTUSAN,A.KODE_PERK,B.NO_AC,B.TGL_AC,B.NO_AKTA
FROM DATA_REGISTER A LEFT JOIN DATA_REG_AC B ON A.NO_PERK=B.NO_PERK
WHERE ((LEFT(A.KODE_PERK,2)='CG') OR (LEFT(A.KODE_PERK,2)='GC') or
LEFT(KODE_PERK,1)='7') AND (A.TGL_PUTUSAN IS NOT NULL) AND
(B.TGL_AC IS NULL) AND (YEAR(A.TGL_DAFTAR)=2013) ORDER BY A.TGL_PUTUSAN ASC