Re: Column as result of subtraction of two other columns?

Поиск
Список
Период
Сортировка
От Mark Cave-Ayland
Тема Re: Column as result of subtraction of two other columns?
Дата
Msg-id 8F4A22E017460A458DB7BBAB65CA6AE5026612@openmanage
обсуждение исходный текст
Ответ на Column as result of subtraction of two other columns?  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: Column as result of subtraction of two other columns?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Column as result of subtraction of two other columns?