Re: Column as result of subtraction of two other columns? - Mailing list pgsql-general

From Mark Cave-Ayland
Subject Re: Column as result of subtraction of two other columns?
Date
Msg-id 8F4A22E017460A458DB7BBAB65CA6AE5026612@openmanage
Whole thread Raw
In response to Column as result of subtraction of two other columns?  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
List pgsql-general
> -----Original Message-----
> From: John Sidney-Woollett [mailto:johnsw@wardbrook.com]
> Sent: 16 July 2004 16:22
> To: Bruno Wolff III
> Cc: Mark Cave-Ayland; pgsql-general@postgresql.org
> Subject: Re: [GENERAL] Column as result of subtraction of two
> other columns?
>
>
> Try
>
> select a, b, (b - a) as diff from (
>   select 1 as a, 2 as b
> ) as tmp;
>
> John Sidney-Woollett


Hi John,

Brilliant - thanks for this! The reason I would like to do it this way
is because in my real database, both a and b are horribly complex with 6
or more joins, and it seems a waste for the database to calculate both
results again just to give the difference. I'll give this a go on Monday
and shout if I still can't get it to work.


Many thanks,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.



pgsql-general by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: Column as result of subtraction of two other columns?
Next
From: Tom Lane
Date:
Subject: Re: Column as result of subtraction of two other columns?