0

The data contains over 360K numbers so make sure the query is optimised.

DATABASE

TABLE consist of data

+---------+
| Styles  |
+---------+
|  1 
|  2
|  3
|  4
|  7
|  8
|  9
|  10 
+---------+

Numbers i HAVE

+--------+
|Numbers |
+--------+
| 4
| 5  
| 6 
| 9 
+--------+

Numbers NOT IN Styles are suppose 5,6 how do I get them.

Thanks

imvp
  • 123
  • 1
  • 11

2 Answers2

0

Use left or right join this sample is using left joint

select b.col1, 'is missing'
from    (values(1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) as b(col1)
        left join (values(1),(2),(3),(4),(5),(6),(9),(10)) as a(col1) on b.col1 = a.col1
where   a.col1 is null
Jules
  • 1,423
  • 13
  • 22
0

Create the ten numbers you are interested in on-the-fly and remove those present in the table. E.g.:

select row_number() over (order by bus_id) from table fetch first 10 rows only
except
select bus_id from table;

The syntax depends on the DBMS of course. You may be using a DBMS where you'd work with rownum, limit, top, minus, a values clause or whatever instead.

Thorsten Kettner
  • 89,309
  • 7
  • 49
  • 73