POW – Fill In The Blanks In SQL

One of the things I always find interesting is the fact that DBAs almost always use some type of auto-increment method in order to generate unique IDs for records. Sometimes, though, you may have a table in which you don’t want to use the default method of generating the next ID in the sequence. Sometimes the goal is to re-use old IDs that are no longer in use. The goal this week will be to create a SELECT statement in any flavor of SQL you want, that will fetch the smallest non-negative positive integer that has not yet been used. The column will be called id while the table will be called stars. What is your most efficient way that you can think of the accomplish this task using just a SELECT statement (not a self-written function)?

The answer to this Problem of the Week is here.

One Reply to “POW – Fill In The Blanks In SQL”

Leave a Reply

Your email address will not be published. Required fields are marked *