Sql 我们可以在select子句中使用关系运算符吗
我想制作一列,其中我的金额小于某个值。当我尝试此操作时,查询将运行Sql 我们可以在select子句中使用关系运算符吗,sql,oracle11g,Sql,Oracle11g,我想制作一列,其中我的金额小于某个值。当我尝试此操作时,查询将运行 select LOSA_APP.app_ref_no AS "App.Ref.No.", LOSA_EXP_SUMM_Z.group_exp AS "Group Exposure Amount", LOSA_EXP_SUMM_Z.group_exp - 25000 AS "Less than", columns AS "some Name" columns AS "some Name" from
select LOSA_APP.app_ref_no AS "App.Ref.No.",
LOSA_EXP_SUMM_Z.group_exp AS "Group Exposure Amount",
LOSA_EXP_SUMM_Z.group_exp - 25000 AS "Less than",
columns AS "some Name"
columns AS "some Name"
from
losa_app LOSA_APP
INNER JOIN
code_branch CODE_BRANCH
ON
LOSA_APP.attend_branch = CODE_BRANCH.branch_id
....
where
LOSA_APP.app_status in ('A','R')
and
....
or
(
'&&aplication' = 'Enhancement'
and
(
nvl(LOSA_APP.review_type, '-') IN ('Enhancement', 'Additional') and nvl(LOSA_APP.review_freq, '-') IN ('Enhancement', 'New')
)
);
但是,当我将行LOSA\u EXP\u sum\u Z.group\u EXP-25000更改为“小于”
时,将LOSA\u EXP\u sum\u Z.group\u EXP<25000更改为“小于”
,那么我得到的错误是
ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"
*Cause:
*Action:
Error at Line: 3 Column: 34
第3行是LOSA\u EXP\u SUMM\u Z.group\u EXP<25000,表示“小于”
。当我们使用减号并在关系运算符的情况下给出错误时,为什么会出现这种情况
谢谢如果要在选择中使用关系运算符
,则需要在案例
语句中使用它,如下所示:
select LOSA_APP.app_ref_no AS "App.Ref.No.",
LOSA_EXP_SUMM_Z.group_exp AS "Group Exposure Amount",
CASE
WHEN LOSA_EXP_SUMM_Z.group_exp < 25000
then 'true'
else 'false'
end AS "Less than",
columns AS "some Name"
columns AS "some Name"
from losa_app LOSA_APP
INNER JOIN code_branch CODE_BRANCH
ONLOSA_APP.attend_branch = CODE_BRANCH.branch_id
....
where LOSA_APP.app_status in ('A','R')
and
....
or
(
'&&aplication' = 'Enhancement'
and
(
nvl(LOSA_APP.review_type, '-') IN ('Enhancement', 'Additional') and nvl(LOSA_APP.review_freq, '-') IN ('Enhancement', 'New')
)
);
select LOSA_APP.app_ref_no AS "App.Ref.No.",
LOSA_EXP_SUMM_Z.group_exp AS "Group Exposure Amount",
CASE WHEN LOSA_EXP_SUMM_Z.group_exp < 25000
then LOSA_EXP_SUMM_Z.group_exp - 25000
else LOSA_EXP_SUMM_Z.group_exp end AS "Less than",
columns AS "some Name"
columns AS "some Name"
from losa_app LOSA_APP
INNER JOIN code_branch CODE_BRANCH
ONLOSA_APP.attend_branch = CODE_BRANCH.branch_id
....
where LOSA_APP.app_status in ('A','R')
and
....
or
(
'&&aplication' = 'Enhancement'
and
(
nvl(LOSA_APP.review_type, '-') IN ('Enhancement', 'Additional') and nvl(LOSA_APP.review_freq, '-') IN ('Enhancement', 'New')
)
);