From: | Vik Fearing <vik(at)postgresfriends(dot)org> |
---|---|
To: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Row pattern recognition |
Date: | 2023-06-28 22:30:43 |
Message-ID: | d5e469b6-2486-7569-e4da-1528b3b41d8c@postgresfriends.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 6/28/23 14:17, Tatsuo Ishii wrote:
> Small question.
>
>> This query (with all the defaults made explicit):
>>
>> SELECT s.company, s.tdate, s.price,
>> FIRST_VALUE(s.tdate) OVER w,
>> LAST_VALUE(s.tdate) OVER w,
>> lowest OVER w
>> FROM stock AS s
>> WINDOW w AS (
>> PARTITION BY s.company
>> ORDER BY s.tdate
>> ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
>> EXCLUDE NO OTHERS
>> MEASURES
>> LAST(DOWN) AS lowest
>> AFTER MATCH SKIP PAST LAST ROW
>> INITIAL PATTERN (START DOWN+ UP+)
>> DEFINE
>> START AS TRUE,
>> UP AS price > PREV(price),
>> DOWN AS price < PREV(price)
>> );
>
>> LAST(DOWN) AS lowest
>
> should be "LAST(DOWN.price) AS lowest"?
Yes, it should be. And the tdate='07-08-2023' row in the first
resultset should have '07-08-2023' and '07-10-2023' as its 4th and 5th
columns.
Since my brain is doing the processing instead of postgres, I made some
human errors. :-)
--
Vik Fearing
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2023-06-28 22:31:01 | Re: Add GUC to tune glibc's malloc implementation. |
Previous Message | Tom Lane | 2023-06-28 22:10:09 | Re: several attstattarget-related improvements |