Kamis, 19 Januari 2012

Query Iseng

update TrMasterIncentive set idscheme=idscheme2 from TrMasterIncentive aaa inner join (
    select *
    from (
        select distinct b.idstructure, a.idscheme, c.idscheme idscheme2, c.iscombo
        from TrMasterIncentive a
        inner join TrRekapIdCovJob b on (a.idstructure=b.idstructure)
        inner join mscheme c on (b.idjob=c.idjob and b.idsubcat=c.idsubcat AND IsActive = 'T' and b.iscombo=0 and ('2012-01-01' between c.StartDate and c.EndDate))
        where idcat=10 and a.idlogincentive=162
        union
        select distinct b.idstructure, a.idscheme, c.idscheme idscheme2, c.iscombo
        from TrMasterIncentive a
        inner join TrRekapIdCovJob b on (a.idstructure=b.idstructure)
        inner join mscheme c on (b.idjob=c.idjob and b.idsubcat=c.idsubcat AND IsActive = 'T' and b.iscombo=1 and ('2012-01-01' between c.StartDate and c.EndDate))
        where b.iscombo=1 and a.idlogincentive=162
        union
        select distinct b.idstructure, a.idscheme, c.idscheme idscheme2, c.iscombo
        from TrMasterIncentive a
        inner join TrRekapIdCovJob b on (a.idstructure=b.idstructure)
        inner join mscheme c on (b.idjob=c.idjob and b.idsubcat=c.idsubcat AND IsActive = 'T' and ('2012-01-01' between c.StartDate and c.EndDate))
        where b.idjob in(1,24) and a.idlogincentive=162
    ) xyz
) bbb on (aaa.idstructure=bbb.idstructure)

0 comments:

Posting Komentar

About Me

Koral Web
Kami adalah web developer. Beberapa produk yang pernah kami buat antara lain website, aplikasi klinik, aplikasi apotik, aplikasi EDMS (Electronic Database Management System), Energy Consumption Management System, RKBI (Rencana Kunjungan Barang Import) dan lain-lain sesuai dengan request dari client kami. Jika Anda tertarik untuk membuat system atau aplikasi, jangan sungkan-sungkan menghubungi kami.
Lihat profil lengkapku

Bahasa Pemrogramanmu?

Nasihat

Barangsiapa capek lelah dan letihnya bukan karena Allah maka celakalah dia
Diberdayakan oleh Blogger.

Blog Archieve

SMS Gratis