FW: SQL rolling window without aggregation

From: "Huang, Suya" <Suya(dot)Huang(at)au(dot)experian(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: FW: SQL rolling window without aggregation
Date: 2014-12-07 23:13:35
Message-ID: D83E55F5F4D99B4A9B4C4E259E6227CD1F670007@AUX1EXC02.apac.experian.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It seems like it's not been sent to the SQL group, so I'm trying with this group.

Thanks,
Suya

From: Huang, Suya
Sent: Friday, December 05, 2014 6:25 PM
To: 'pgsql-sql(at)postgresql(dot)org'
Subject: [SQL] rolling window without aggregation

Hi SQL experts,

I've got a question here, is that possible to implement a window function without aggregation? Any SQL could get below desired result?

For example:

Table input
date | id
------------+--------
2014-04-26 | A
2014-05-03 | B
2014-05-10 | C
2014-05-17 | D
2014-05-24 | E
2014-05-31 | F

Expected output, use 2 week roll up as an example:
date | id
------------+--------
2014-04-26 | A
2014-05-03 | A
2014-05-03 | B
2014-05-10 | B
2014-05-10 | C
2014-05-17 | C
2014-05-17 | D
2014-05-24 | D
2014-05-24 | E
2014-05-31 | E
2014-05-31 | F

Thanks,
Suya

Responses

Browse pgsql-general by date

  From Date Subject
Next Message AJ Welch 2014-12-08 00:42:08 Re: FW: SQL rolling window without aggregation
Previous Message Sérgio Saquetim 2014-12-07 22:25:48 Re: Strange behavior in generate_series(date, date, interval) with DST