Created
April 19, 2021 15:50
-
-
Save aev-mambro2/f884de85d10cd759b8535086e3d069a3 to your computer and use it in GitHub Desktop.
Get difference between 2 lists of values in T-SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Using common table expressions | |
with | |
-- Supply list A | |
a (i) as (select i from (values | |
('6GA00215S'), | |
('6GU00208S'), | |
('6PO00396I'), | |
('6PO00398I') | |
) A(i)), | |
-- Supply list B | |
b (i) as (select i from (values | |
('6GA00215S'), | |
('6GU00208S') | |
) B(i)) | |
-- Find all elements in list A that don't exist in list B | |
select a.i from a left join b on a.i = b.i where b.i is null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment