簡體   English   中英

從oracle的列的值集中減去一些常數值

[英]minus a set of some constant values from a set of values of a column in oracle

有一個像id- name-roll這樣的表我有一些恆定的給定值roll like-(1,2,6,8,5)的集合讓它被設置一個表有roll like(1,2,3,4 ,5,6,7)設為集合B我想知道AB表示那些不在表中但存在於給定常量集合A中的roll值

我嘗試從“表名”中選擇卷,而不是卷(1,2,6,8,5); 但它返回正好相反-它返回BA,但我要AB請幫助我也嘗試過

從雙減中選擇(1,2,6,8,5)從表名中選擇滾動; 但是它會產生一些同步錯誤

這是你想要的嗎?

select a.*
from (select 1 as id from dual union all
      select 2 as id from dual union all
      select 6 as id from dual union all
      select 8 as id from dual union all
      select 5 as id from dual
     ) a
where not exists (select 1 from b where a.id = b.id);
(select 1 as id from dual
         union all
select 2 from dual
         union all
select 6 from dual
         union all
select 8 from dual
         union all
select 5 from dual
         )
minus
Select id from b

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM