postgresql - SQL: Get list of numbers not in use by other rows -


i'm using postgresql 8.1.17, , have table account numbers. acceptable range account number number between 1 , 1,000,000 (a 6 digit number). column "acctnum" contains account number. selecting numbers in use easy (select acctnum tbl_acct_numbers order acctnum). select numbers in acceptable range not in use, is, aren't found in rows within column acctnum.

select     new_number     generate_series(1, 1000000) new_number         left join tbl_acct_numbers on new_number = acctnum     acctnum null; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -