SQL query exception -
the following query excludes accounts amt
balance 0.
although trying make exception accounts l1_org_seg_id = 101, 102 , 105
if it's value equal 0.
can point me right direction? thanks!
select 'table' cola ,o.l1_org_seg_id colb ,a.l1_acct_seg_id colc ,a.l2_acct_seg_id cold ,a.l3_acct_seg_id cole ,' ' colf ,a.acct_name colg ,'usd' colh ,sum(g.amt) coli ,' ' colj ,' ' colk ,' ' coll ,' ' colm ,'4' coln ,'2015' colo ,'4/24/15' colp ,' ' colq ,' ' colr ,' ' cols ,' ' colt ,' ' colu ,' ' colv gl_post_sum g inner join acct on a.acct_id = g.acct_id inner join org o on o.org_id = g.org_id g.fy_cd = '2015' , g.pd_no < 5 , a.s_acct_type_cd in ( 'l' ,'a' ) , g.org_id not 'j%' , a.active_fl = 'y' , o.l1_org_seg_id not in ( '125' ,'126' ,'127' ,'129' ) group o.l1_org_seg_id ,a.l1_acct_seg_id ,a.l2_acct_seg_id ,a.l3_acct_seg_id ,a.acct_name having sum(g.amt) <> 0 order 2
something should work
select 'table' cola,o.l1_org_seg_id colb,a.l1_acct_seg_id colc, a.l2_acct_seg_id cold,a.l3_acct_seg_id cole, ' ' colf,a.acct_name colg, 'usd' colh,sum(g.amt) coli,' ' colj,' ' colk,' ' coll,' ' colm,'4' coln,'2015' colo, '4/24/15' colp,' ' colq,' ' colr,' ' cols,' ' colt,' ' colu,' ' colv gl_post_sum g join acct on a.acct_id = g.acct_id join org o on o.org_id = g.org_id g.fy_cd='2015' , g.pd_no < 5 , a.s_acct_type_cd in ('l','a') , g.org_id not 'j%' , a.active_fl = 'y' , o.l1_org_seg_id not in ('125', '126', '127', '129') group o.l1_org_seg_id,a.l1_acct_seg_id,a.l2_acct_seg_id,a.l3_acct_seg_id,a.acct_name having sum(g.amt) <> 0 or o.l1_org_seg_id in (101, 102, 105) order 2
Comments
Post a Comment