Search Postgresql Archives

Re: Missing numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 generate_series ((SELECT min(doc_numero) FROM bdocs),
                      (SELECT max(doc_numero) FROM bdocs)) AS g(num)
WHERE g.num NOT IN (select doc_numero
		   from bdocs
		   where doc_numero is not null)

is more likely to return a correct answer, since
bdocs.doc_numero will never equal g,num when it is also NULL

Yes, it worked pretty fine. Thanks.

--
Sinceramente,
Josué Maldonado.

... "Cultura es el paso que nos queda después de haber olvidado todo lo aprendido."

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux