Re: [GENERAL] Missing numbers

2005-06-01 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > On Wed, 2005-06-01 at 00:27 -0400, Alvaro Herrera wrote: >>> SELECT g.num >>> FROM generate_series ((SELECT min(doc_numero) FROM bdocs), >>> (SELECT max(doc_numero) FROM bdocs)) AS g(num) >>> LEFT JOIN bdocs ON bdocs.doc_numero = g.num >>> WHERE bdocs.doc_n

Re: [GENERAL] Missing numbers

2005-06-01 Thread Dan Black
you can also try this =) select   o1.doc_numero+1 as first,   ((select doc_numero from bdocs where id > o1.doc_numero+1 order by doc_numero limit 1))-1 as last from bdocs as o1 where o1.doc_numero+1 not in (select o2.doc_numero from bdocs as o2) order by doc_numero2005/5/31, josue <[EMAIL PR

Re: [GENERAL] Missing numbers

2005-06-01 Thread josue
Simon Riggs wrote: You could use something like that: SELECT g.num FROM generate_series ((SELECT min(doc_numero) FROM bdocs), (SELECT max(doc_numero) FROM bdocs)) AS g(num) LEFT JOIN bdocs ON bdocs.doc_numero = g.num WHERE bdocs.doc_numero IS NULL SELECT g.num FROM gener

Re: [GENERAL] Missing numbers

2005-06-01 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Simon Riggs <[EMAIL PROTECTED]> writes: > If the WHERE clause said bdocs.doc_numero > 7 we would hope that this > was applied before the join. Stating this would change the OUTER into an INNER JOIN, and this would imply that the order of the restrictions is irrelev

Re: [GENERAL] Missing numbers

2005-06-01 Thread Simon Riggs
On Wed, 2005-06-01 at 00:27 -0400, Alvaro Herrera wrote: > On Wed, Jun 01, 2005 at 01:21:28AM +0100, Simon Riggs wrote: > > On Tue, 2005-05-31 at 18:28 +0200, Harald Fuchs wrote: > > > > SELECT g.num > > > FROM generate_series ((SELECT min(doc_numero) FROM bdocs), > > > (SELE

Re: [GENERAL] Missing numbers

2005-05-31 Thread Alvaro Herrera
On Wed, Jun 01, 2005 at 01:21:28AM +0100, Simon Riggs wrote: > On Tue, 2005-05-31 at 18:28 +0200, Harald Fuchs wrote: > > SELECT g.num > > FROM generate_series ((SELECT min(doc_numero) FROM bdocs), > > (SELECT max(doc_numero) FROM bdocs)) AS g(num) > > LEFT JOIN bdocs ON bdoc

Re: [GENERAL] Missing numbers

2005-05-31 Thread Simon Riggs
On Tue, 2005-05-31 at 18:28 +0200, Harald Fuchs wrote: > In article <[EMAIL PROTECTED]>, > josue <[EMAIL PROTECTED]> writes: > > > Hello list, > > I need to track down the missing check numbers in a serie, table > > contains a column for check numbers and series like this: > > > > dbalm=# select

Re: [GENERAL] Missing numbers

2005-05-31 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, josue <[EMAIL PROTECTED]> writes: > Hello list, > I need to track down the missing check numbers in a serie, table > contains a column for check numbers and series like this: > dbalm=# select doc_numero,doc_ckseriesfk from bdocs where doc_cta=1 > dbalm-# and doc_t

[GENERAL] Missing numbers

2005-05-31 Thread josue
Hello list, I need to track down the missing check numbers in a serie, table contains a column for check numbers and series like this: dbalm=# select doc_numero,doc_ckseriesfk from bdocs where doc_cta=1 dbalm-# and doc_tipo='CHE' order by doc_numero; doc_numero | doc_ckseriesfk +-