Referencing subselect returned value - Mailing list pgsql-general

From Marco Lazzeri
Subject Referencing subselect returned value
Date
Msg-id 1074630115.2946.43.camel@macbeth.intranet.noze.it
Whole thread Raw
Responses Re: Referencing subselect returned value
List 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


pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Getting rid of duplicate tables.
Next
From: Alvaro Herrera
Date:
Subject: Re: PostgreSQL and Datawarehouse tools