DATA set Query Help
Hi i need some help with dataset query(query mentioned below). I want that condition acct_cls_flg='N' ( highlighted in bold) should not be processed if user enters one this CloseDateLow parameter. Condition should be processed in every other case select * from table1 where acct_cls_flg='N' and sol_id=@Solid and acct_crncy_code=@Ccy and (gl_sub_head_code = @GlCode Or @GlCode Is Null) and (schm_code = @SchemeCode Or @SchemeCode Is Null) and (schm_type = @SchemeType Or @SchemeType Is Null) and (acct_opn_date >= @OpenDateLow Or @OpenDateLow Is Null) and (acct_opn_date <= @OpenDateHigh Or @OpenDateHigh Is Null) and (acct_cls_date >= @CloseDateLow Or @CloseDateLow Is Null) and (acct_cls_date <= @CloseDateHigh Or @CloseDateHigh Is Null) AND ( CASE WHEN @CifId IS NULL THEN '!@!' ELSE acid END IN ( SELECT acid FROM tbaadm.acct_auth_sign_table WHERE cust_id = ( SELECT cust_id FROM TBAADM.vCMGC WHERE cif_id = @CifId ) UNION SELECT '!@!' WHERE @CifId IS NULL ) ) order by foracidkulbir
August 7th, 2012 1:41pm

Hi Kulbir, I remember we had solved a similar such scenario a while ago... Here's what you can try doing this time: select * from table1 where acct_cls_flg = CASE WHEN @CloseDateLow IS NULL THEN 'N' ELSE acct_cls_flag END and sol_id=@Solid and acct_crncy_code=@Ccy and (gl_sub_head_code = @GlCode Or @GlCode Is Null) and (schm_code = @SchemeCode Or @SchemeCode Is Null) and (schm_type = @SchemeType Or @SchemeType Is Null) and (acct_opn_date >= @OpenDateLow Or @OpenDateLow Is Null) and (acct_opn_date <= @OpenDateHigh Or @OpenDateHigh Is Null) and (acct_cls_date >= @CloseDateLow Or @CloseDateLow Is Null) and (acct_cls_date <= @CloseDateHigh Or @CloseDateHigh Is Null) AND ( CASE WHEN @CifId IS NULL THEN '!@!' ELSE acid END IN ( SELECT acid FROM tbaadm.acct_auth_sign_table WHERE cust_id = ( SELECT cust_id FROM TBAADM.vCMGC WHERE cif_id = @CifId ) UNION SELECT '!@!' WHERE @CifId IS NULL ) ) order by foracid Please let me know if this does not solve your requirement. HTH. Cheers, IceQB Please mark correct answers :)
Free Windows Admin Tool Kit Click here and download it now
August 7th, 2012 2:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics