pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Raj Mathur (राज माथुर) <raju@linux-delhi.org>
To: pgsql-sql@postgresql.org
Cc: Andreas Kretschmer <akretschmer@spamfence.net>
Subject: Re: Simple way to get missing number
Date: Tue, 24 Apr 2012 20:59:40 +0530
Message-ID: <201204242059.40709.raju@linux-delhi.org> (raw)
In-Reply-To: <20120424143655.GA7501@tux>
References: <4F96B57E.8080306@encs.concordia.ca>
	<20120424143655.GA7501@tux>

On Tuesday 24 Apr 2012, Andreas Kretschmer wrote:
> Emi Lu <emilu@encs.concordia.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@kandalaya.org   || GPG:
http://otheronepercent.blogspot.com || http://kandalaya.org || CC68
It is the mind that moves           || http://schizoid.in   || D17F



view thread (10+ messages)  latest in thread

Message-ID: <201204242059.40709.raju@linux-delhi.org>
Permalink:  ../201204242059.40709.raju@linux-delhi.org/
Also on:    postgresql.org/message-id/201204242059.40709.raju@linux-delhi.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: raju@linux-delhi.org, akretschmer@spamfence.net
  Subject: Re: Simple way to get missing number
  In-Reply-To: <201204242059.40709.raju@linux-delhi.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox