带减号运算符问题的Oracle查询

带减号运算符问题的Oracle查询,oracle,plsql,Oracle,Plsql,我试图通过比较两个表来提取数据库中的某些用户。我的问题是: select 'alter user '||username||' identified by "kRobGc3$vs0cmzX";' from dba_users where default_tablespace='APPS_TS_TX_DATA' and username not in ('John','Stacey','Mark','Jim') minus select oracle_username fro

我试图通过比较两个表来提取数据库中的某些用户。我的问题是:

select 'alter user '||username||' identified by "kRobGc3$vs0cmzX";'
from dba_users
where default_tablespace='APPS_TS_TX_DATA'
and username not in ('John','Stacey','Mark','Jim')
minus 
select oracle_username from FND_ORACLE_USERID;
所以当我执行上面的查询时,它会返回通过我的第一次选择过滤的用户,并以某种方式绕过负第二次选择

你知道怎么处理吗


谢谢

看起来您需要一个子查询

select 'alter user '||username||' identified by "kRobGc3$vs0cmzX";'
from (select username
        from dba_users
        where default_tablespace = 'APPS_TS_TX_DATA'
          and username not in ('John', 'Stacey', 'Mark', 'Jim')
      minus 
      select oracle_username 
        from FND_ORACLE_USERID
     );

看起来您需要一个子查询

select 'alter user '||username||' identified by "kRobGc3$vs0cmzX";'
from (select username
        from dba_users
        where default_tablespace = 'APPS_TS_TX_DATA'
          and username not in ('John', 'Stacey', 'Mark', 'Jim')
      minus 
      select oracle_username 
        from FND_ORACLE_USERID
     );