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)
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)
Langganan:
Posting Komentar (Atom)
Blog Archive
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.
Bahasa Pemrogramanmu?
Nasihat
Barangsiapa capek lelah dan letihnya bukan karena Allah maka celakalah dia
Diberdayakan oleh Blogger.
Web Sunnah
Blog Archieve
- Info (3)
- Kajian (3)
- My Program (1)
- Orang Terkenal (1)
- scrip (2)
- SQL (23)
- Subquery (9)
- Trik (13)
0 comments:
Posting Komentar