如何将列值设置为null在oracle中选择查询?



我想选择一个列值等于一个特定的页面项值,并选择其他值为空。主表数据如下:

tbody> <<tr>1
id first_numbers second_numbers
111122222
34341112

使用CASE表达式:

样本数据:

SQL> with test (id, first_numbers, second_numbers) as
2    (select 1, 1112, 2222 from dual union all
3     select 2, 3434, 1112 from dual
4    )

查询本身:

5  select id,
6    case when first_numbers  <> &&P4_NUMBER then null else first_numbers  end first_numbers,
7    case when second_numbers <> &&P4_NUMBER then null else second_numbers end second_numbers
8  from test;
Enter value for p4_number: 1112
ID FIRST_NUMBERS SECOND_NUMBERS
---------- ------------- --------------
1          1112
2                         1112
SQL>

当您使用Apex时,您将使用绑定(而不是替换)变量,即

... case when first_numbers  <> :P4_NUMBER then
^
|
this

相关内容

  • 没有找到相关文章

最新更新