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

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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

pgsql-sql by date

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

pgsql-general by date

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

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