DB2 SQL Query Filtering rows based on multiple fields
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')
精彩评论