Re: Migration from DB2 to PostgreSQL-ROLLUP()

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: sachin kotwal <kotsachin(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Migration from DB2 to PostgreSQL-ROLLUP()
Date: 2013-06-19 18:59:11
Message-ID: CAHyXU0zJ5Em7C9C18PC1ZQxV60-WVvuhMa_atU_GUna_HfZWGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 19, 2013 at 3:56 AM, sachin kotwal <kotsachin(at)gmail(dot)com> wrote:
> While migrating my application from DB2 to PostgreSQL.
>
> I want to migrate ROLLUP() function in PostgreSQL.
>
> Example:
> SELECT WEEK(SALES_DATE) AS WEEK,
> DAYOFWEEK(SALES_DATE) AS DAY_WEEK,
> SUM(SALES) AS UNITS_SOLD
> FROM SALES
> GROUP BY ROLLUP ( WEEK(SALES_DATE), DAYOFWEEK(SALES_DATE) )
> ORDER BY WEEK, DAY_WEEK
>
> This example shows two simple ROLLUP queries followed by a query which
> treats the two ROLLUPs as grouping sets in a single result set and specifies
> row ordering for each column involved in the grouping sets.
>
> How can I migrate ROLLUP() function in PostgreSQL? or is there any similar
> function in PostgreSQL which can done this job?

Yeah, we don't have it. To work around the problem I typically
create a function or a view dynamically, that takes a template and
forces the rollup with a UNION ALL. This technique is not generic,
so each case has to be handled specially. Lack of OLAP style sql
features is #2 missing feature for me in postgres (after stored
procedures).

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message karen chau 2013-06-19 20:13:32 Problem with connection
Previous Message Victor Yegorov 2013-06-19 18:56:32 Re: postgresql query