Skip site navigation (1) Skip section navigation (2)

Re: Simple way to get missing number

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Simple way to get missing number
Date: 2012-04-24 14:36:55
Message-ID: 20120424143655.GA7501@tux (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:

> Good morning,
>
> May I know is there a simple sql command which could return missing  
> numbers please?
>
> For example,
>
> t1(id integer)
>
> values= 1, 2, 3 .... 5000000
>
> select miss_num(id)
> from   t1 ;

something like 

,----[  code  ]
| test=# select * from emi_lu ;
|  i
| ---
|  1
|  2
|  3
|  5
|  6
|  8
|  9
| (7 rows)
|
| Time: 0,246 ms
| test=*# select * from generate_Series(1,10) s left join emi_lu on
| (s=emi_lu.i) where i is null;
|  s  | i
| ----+---
|   4 |
|   7 |
|  10 |
| (3 rows)
`----

this?




Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

In response to

Responses

pgsql-sql by date

Next:From: Alban HertroysDate: 2012-04-24 14:41:26
Subject: Re: Simple way to get missing number
Previous:From: hubert depesz lubaczewskiDate: 2012-04-24 14:31:39
Subject: Re: Simple way to get missing number

pgsql-general by date

Next:From: Alban HertroysDate: 2012-04-24 14:41:26
Subject: Re: Simple way to get missing number
Previous:From: hubert depesz lubaczewskiDate: 2012-04-24 14:31:39
Subject: Re: Simple way to get missing number

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group