开发者

DB2 SQL Query Filtering rows based on multiple fields

开发者 https://www.devze.com 2022-12-07 22:23 出处:网络
I need to write a query based on the following conditions: Within one table, the following condition must be met:

I need to write a query based on the following conditions:

Within one table, the following condition must be met:

table name: DLS_RBM_RBI columns within the table

  • RBM_3_CD must be blank
  • If RBM_3_CD is blank, then RBM_2_CD must be 1
  • If RBM_3_CD is blank and RBM_2_CD is blank, then RBM_1_CD must be 1

How would these conditions be coded in a SQL statement? In an IF within a where clause or case in a select?

I tried using a where clause with these conditions.

 AND (D.RBM_3_CD = '') 
        OR (D.RBM_3_CD = '' AND D.RBM_2_CD = '1') 
        OR (D.RBM_3_CD = '' AND RBM_2开发者_开发百科_CD = '' AND RBM_1_CD = '1') 
0

精彩评论

暂无评论...
验证码 换一张
取 消