基于条件表中的条件筛选目标数据表中的行
Alright, let's walk through this filtering task step by step. First, let's clearly present the source data and condition rules, then apply each rule to find the valid rows.
Source Data Table (Rows to Filter)
| ID | business | has_agreement | flag_type |
|---|---|---|---|
| 118 | 99 | YES | 1 |
| 119 | 99 | YES | 2 |
| 120 | 100 | YES | 3 |
| 121 | 100 | YES | 1 |
| 122 | 100 | NO | 2 |
| abcd | 2300 | YES | 4 |
| ' ' | 788 | NO | 1 |
Condition Rules Table (PRE-3 Condition Set)
All conditions in the same condition_id group are AND rules (must all be satisfied), and all three groups belong to the same condition_set PRE-3 — so every group's rules must pass for a row to be accepted.
| condition_id | condition_set | sequence_id | field_name | operator | value |
|---|---|---|---|---|---|
| 1 | PRE-3 | 1 | ID | != | NULL |
| 1 | PRE-3 | 2 | ID | != | "" |
| 2 | PRE-3 | 1 | business | != | NULL |
| 2 | PRE-3 | 2 | business | != | "" |
| 2 | PRE-3 | 3 | business | >= | 100 |
| 3 | PRE-3 | 1 | has_agreement | != | NULL |
| 3 | PRE-3 | 2 | has_agreement | != | "" |
| 3 | PRE-3 | 3 | has_agreement | = | ... |
Quick Clarifications on Ambiguities
- The third rule in
condition_id 3uses...as a placeholder. I'll assume this is meant to accept any non-null/non-empty value forhas_agreement(since the first two rules in the group already block NULL/empty entries). - The row with ID
' '(a single space) technically passes theID != ""rule (a space isn't an empty string), but if the intent was to exclude whitespace-only IDs, this row would be rejected. I'm sticking to the literal rule for this analysis.
Filtered Result (Accepted Rows)
After applying all rules, these rows meet all criteria:
| ID | business | has_agreement | flag_type |
|---|---|---|---|
| 120 | 100 | YES | 3 |
| 121 | 100 | YES | 1 |
| 122 | 100 | NO | 2 |
| abcd | 2300 | YES | 4 |
| ' ' | 788 | NO | 1 |
Rejected Rows (Why?)
- Rows 1 and 2: Fail the
business >= 100rule (their business value is 99, which is below the threshold).
内容的提问来源于stack exchange,提问作者Pandurang Channadasar
相关产品推荐
相关产品推荐

