Relates to Postgres Generating a Virtual Table in Postgres The key thing here is the Left Join and how to generate a synthetic table of data where there is not one with snomed_data as ( select snomed from ( values (102435003), (102872000), (102955006), (105480006), (105531004), (1087151000119108), (108941000119102), (127040003), (127364007), (128613002), (13213009), (133581000119103), (134781000119106), (1372004), (13746004), (1431000119101), (15188001), (15504009), (15628003), (160303001), (160309002), (160320002), (160321003), (160336000), (160343006), (160364005), (160418004), (160425006), (160575005), (160576006), (160577002), (160603005), (160604004), (160605003), (16090371000119103), (16090611000119100), (16090731000119102), (161466001), (161508001), (161512007), (161580006), (161617006), (161664006), (161765003), (161805006), (161809000), (16216731000119106), (162415008), (16402000), (16468541000119105), (165816005), (169470007), (169471006), (169488004), (169501005), (169508004), (169524003), (169533001), (169539002), (169544009), (169545005), (169548007), (169550004), (169567006), (171207006), (185903001), (190905008), (195967001), (197480006), (197928006), (200936003), (20587003), (218190002), (219006), (224191006), (224974006), (22504001), (237055002), (265636007), (266889000), (266907002), (26843008), (271737000), (275549008), (275881005), (276030007), (276720006), (281022002), (29399001), (297225000), (308817005), (31401003), (315637000), (315638005), (32273002), (32911000), (33839006), (34000006), (34486009), (353295004), (35489007), (360885002), (364699009), (371108009), (372148003), (38341003), (38437003), (397540003), (397942001), (398089004), (404189009), (405633009), (40930008), (409709004), (412750001), (413287003), (413301003), (414408004), (417005), (422651008), (423593006), (423656007), (423797009), (423839002), (424423005), (425022003), (428030001), (428406005), (428582006), (429087003), (429721005), (429746005), (430695000), (430801003), (439733009), (439888000), (440201000124103), (44054006), (441493008), (441882000), (444356002), (450891000124109), (454791000124107), (456671000124106), (46635009), (472954000), (472967002), (472971004), (473117004), (48694002), (52637005), (5602001), (58214004), (58532003), (58703003), (591000119102), (59251000119102), (608848006), (609133009), (64521000119100), (64766004), (65071000119106), (6970001000004107), (69896004), (699128009), (699449003), (700190003), (705329002), (708129006), (709313000), (709881001), (713458007), (717794008), (7200002), (722499006), (723881000), (733423003), (733460004), (733461000), (735930004), (763325000), (763598005), (771412001), (77176002), (78275009), (816150000), (84229001), (8517006), (90708001), (90935002), (92957000), (93871000119101), (94691000119101), (95315005), (95607001), (98251000119101) ) AS t (snomed) ) SELECT snomed, snomed_icd10_mappings.id from snomed_data left join snomed_icd10_mappings on snomed_data.snomed = snomed_icd10_mappings.snomed_code where snomed_icd10_mappings.id is null