Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle sql打印值(如果存在),否则打印“值”不存在_Oracle - Fatal编程技术网

Oracle sql打印值(如果存在),否则打印“值”不存在

Oracle sql打印值(如果存在),否则打印“值”不存在,oracle,Oracle,我正在寻求帮助-如何编写select语句Oracle打印表中的列并检查特定值?对于不存在的值,应打印一条记录,说明“值”不存在 例如 预期产量- username ======== a b does not exist c 如果您使用的是最新版本的Oracle,则可以使用outer apply和一个集合来保存您要查找的值: select coalesce (u.username, t.column_value || ' does not exist') as username from tab

我正在寻求帮助-如何编写select语句Oracle打印表中的列并检查特定值?对于不存在的值,应打印一条记录,说明“值”不存在

例如

预期产量-

username
========
a
b does not exist
c

如果您使用的是最新版本的Oracle,则可以使用outer apply和一个集合来保存您要查找的值:

select coalesce (u.username, t.column_value || ' does not exist') as username
from table(sys.odcivarchar2list('SYS', 'XYZ', 'OUTLN')) t
outer apply (select username from all_users u where u.username = t.column_value) u;

USERNAME
------------------------------
SYS
XYZ does not exist
OUTLN
或者只是一个外部连接,这也适用于早期版本:

select coalesce (u.username, t.column_value || ' does not exist') as username
from table(sys.odcivarchar2list('SYS', 'XYZ', 'OUTLN')) t
left join all_users u on u.username = t.column_value;

USERNAME
------------------------------
SYS
XYZ does not exist
OUTLN

很抱歉,如果您将其表述为一个问题而不是一个业务需求,那么您可能会得到更好的回答。这毕竟是一个问答网站,不是免费的咨询服务。
select coalesce (u.username, t.column_value || ' does not exist') as username
from table(sys.odcivarchar2list('SYS', 'XYZ', 'OUTLN')) t
left join all_users u on u.username = t.column_value;

USERNAME
------------------------------
SYS
XYZ does not exist
OUTLN