TSQL Comparing two Sets

后端 未结 6 2153
野的像风
野的像风 2021-01-18 03:58

When two sets are given

s1 ={ a,b,c,d} s2={b,c,d,a}

(i.e)

TableA

Item
a
b
c
d

TableB

Item
b
c
d
a

How to write Sql quer

6条回答
  •  不要未来只要你来
    2021-01-18 04:51

    Could do it with EXCEPT and a case

    select 
       case 
         when count (1)=0 
            then 'Elements in TableA and TableB contains identical sets' 
         else 'Nope' end from (
           select item from s1
          EXCEPT 
           select item from s2
    ) b
    

提交回复
热议问题