From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Sándor Daku <daku(dot)sandor(at)gmail(dot)com> |
Cc: | Kip Warner <kip(at)thevertigo(dot)com>, "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Help with CREATE FUNCTION |
Date: | 2016-04-18 15:00:20 |
Message-ID: | CAKFQuwatpyHOpBDssmEuAx21Q37wJkMXyxvFFC6KvcUMpGzpMA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Mon, Apr 18, 2016 at 3:02 AM, Sándor Daku <daku(dot)sandor(at)gmail(dot)com> wrote:
>
> On 18 April 2016 at 08:22, Kip Warner <kip(at)thevertigo(dot)com> wrote:
>
>> Hey list,
>>
>> I am having difficulty using CREATE FUNCTION with a subordinate SELECT
>> query that should operate on exactly two rows.
>>
>> http://pastebin.com/7b3Vxbuh
>>
>> Any help is appreciated.
>>
> Your select should look like this:
>
> select your_const*abs(ta.col1-tb.col1)+...
> from my_table as ta, my_table as tb where ta.id = arg_id_a and tb.id =
> arg_id_b;
>
> This kind of unqualified join is usually stupid, but in this time exactly
> what you need.
>
>
Arguably its still stupid :)
SELECT [...]
FROM (SELECT * FROM my_table WHERE id = arg_id_a) AS ta
CROSS JOIN (SELECT * FROM my_table WHERE id = arg_id_b) AS tb
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Kip Warner | 2016-04-18 17:26:26 | Re: Help with CREATE FUNCTION |
Previous Message | Sándor Daku | 2016-04-18 10:02:00 | Re: Help with CREATE FUNCTION |