Re: Simple way to get missing number

From: "Raj Mathur ( राज =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=)" <raju(at)linux-delhi(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Cc: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
Subject: Re: Simple way to get missing number
Date: 2012-04-24 15:29:40
Message-ID: 201204242059.40709.raju@linux-delhi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Tuesday 24 Apr 2012, Andreas Kretschmer wrote:
> 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)

Nice one, but curious about how would this perform if the numbers in
question extended into 7 figures or more?

Regards,

-- Raj
--
Raj Mathur || raju(at)kandalaya(dot)org || GPG:
http://otheronepercent.blogspot.com || http://kandalaya.org || CC68
It is the mind that moves || http://schizoid.in || D17F

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Crawford 2012-04-24 15:42:33 Re: [SQL] Simple way to get missing number
Previous Message Andreas Kretschmer 2012-04-24 15:28:53 Re: how robust are custom dumps?

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2012-04-24 15:42:33 Re: [SQL] Simple way to get missing number
Previous Message Emi Lu 2012-04-24 15:21:41 Re: Simple way to get missing number