Re: Function in selection? - Mailing list pgsql-general

From Peter Darley
Subject Re: Function in selection?
Date
Msg-id NNEAICKPNOGDBHNCEDCPAEBBDJAA.pdarley@kinesis-cem.com
Whole thread Raw
In response to Function in selection?  (Dousak "May (Phoebus Apollonus)" <phoebus@email.si>)
Responses Re: Function in selection?  (Dousak "May (Phoebus Apollonus)" <phoebus@email.si>)
Re: Function in selection?  (Dousak "May (Phoebus Apollonus)" <phoebus@email.si>)
List pgsql-general
May,
    I think this is what you want.

SELECT CASE WHEN A=0 and B<>0 THEN B*Z.TABLE_Y ELSE A END AS A, CASE WHEN
A<>0 AND B=0 THEN A/Z.TABLE_Y ELSE B END AS B FROM TABLE_X ORDER BY D, C, E

Thanks,
Peter Darley

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Dousak May
(Phoebus Apollonus)
Sent: Thursday, March 13, 2003 10:56 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Function in selection?


Hi, I want to make really advanced query and I'm not sure it's
possible... it would be "like that":

select A, B, C, D, E, F from TABLE_X ORDER BY D, C, E
  if A==0 AND B!=0 {A=B*Z.TABLE_Y}
  if A!=0 AND B==0 {B=A/Z.TABLE_Y}

OK, I don't really have problems with first line :), but how can I tell
him to select like the second and third line are telling it?
is that possible? :/

Tnx,

May



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: unlock rows
Next
From: Dousak "May (Phoebus Apollonus)"
Date:
Subject: Re: Function in selection?