pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Harald Fuchs <hf0923x@protecting.net>
To: pgsql-sql@postgresql.org
Subject: Re: serial in output
Date: 04 Nov 2005 15:03:01 +0100
Message-ID: <87mzkk4iju.fsf@srv.protecting.net> (raw)
References: <20051028111824.C8C7DDA53F@svr1.postgresql.org>

In article <20051028111824.C8C7DDA53F@svr1.postgresql.org>,
"alessandra de gregorio" <adegregorio@fgscapital.com> writes:

> Hi,
> What function should I use to get a serial number, together with my results,
> from a query?

> Ex. Of output I want:

> 1	ooo	pp	ij
> 2	hou	joo	iu	
> 3	bhi	ft	yh

> Basically, I would like to have one column with integers, from 1 onwards, no
> matter how many tables I join in, or the data that I get back.

I'd do it in application code, but if you insist on doing it at the
SQL layer:

CREATE TEMPORARY SEQUENCE tmpseq;
SELECT nextval('tmpseq'), othercols... FROM ...




view thread (3+ messages)

Message-ID: <87mzkk4iju.fsf@srv.protecting.net>
Permalink:  ../87mzkk4iju.fsf@srv.protecting.net/
Also on:    postgresql.org/message-id/87mzkk4iju.fsf@srv.protecting.net

 · 

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: hf0923x@protecting.net
  Subject: Re: serial in output
  In-Reply-To: <87mzkk4iju.fsf@srv.protecting.net>

* 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