문제

I have a table:

num type flag
--- ---- ----
11   A    1
12   A    1
13   A    1
14   A    1
15   A    1

12   B    2
13   B    2

How would I write a query to get the following result:

num type flag
--- ---- ----
11   A     1
14   A     1
15   A     1
도움이 되었습니까?

해결책

select num
from your_table
where num not in
(
  select num
  from your_table
  where type = 'B'
)

다른 팁

Try to use not exists as below

select * 
from tab  t
where t.type = 'A'
and not exists 
(
  select 1
  from tab t1
  where t1.type = 'B'
  and t1.num=t.num

)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top