Referencing subselect returned value

From: Marco Lazzeri <marcomail(at)noze(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Referencing subselect returned value
Date: 2004-01-20 20:21:56
Message-ID: 1074630115.2946.43.camel@macbeth.intranet.noze.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'd like to reference values returned by a subselect in the same SELECT
query.

Example:

SELECT id,
( SELECT COUNT(*) FROM second ) AS value_to_reference,
( value_to_reference + 1 ) AS value_that_uses_referenced_one
FROM first;

Any suggestions?

Thank you,
Marco

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2004-01-20 21:43:30 Re: PostgreSQL and Datawarehouse tools
Previous Message Richard Huxton 2004-01-20 19:52:43 Re: Getting rid of duplicate tables.