Thursday, 26 July 2012
#20 Join table dengan data yang di select


select distinct a.tahun, a.bulan, a.tanggal, userid from (
select distinct year(logtime) tahun, month(logtime) bulan, day(logtime) tanggal
from ngac_log
where year(logtime)=2012 and month(logtime)=5
)a left join (
select distinct userid, year(logtime) tahun, month(logtime) bulan, day(logtime) tanggal
from ngac_log
where year(logtime)=2012 and month(logtime)=5 and userid='002412430000000'
) b on (a.tahun=b.tahun and a.bulan=b.bulan and a.tanggal=b.tanggal)
order by 3
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment