Re: Migration from DB2 to PostgreSQL-ROLLUP()

From: Pavel Stehule <pavel(dot)stehule(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 11:18:54
Message-ID: CAFj8pRBkh_6hDMya2hacBC+6TnEm5YmmnU_BLAv1tP2__zZrxA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2013/6/19 sachin kotwal <kotsachin(at)gmail(dot)com>:
> 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?

this functionality is not supported

you should to rewrite query

SELECT .. FROM GROUP BY weeks(sales_date), dayofweek(salesdate) UNION
ALL SELECT ... FROM .. GROUP BY dayofweek(salesdate) ORDER BY ..

Regards

Pavel Stehule

>
>
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/Migration-from-DB2-to-PostgreSQL-ROLLUP-tp5759825.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2013-06-19 13:45:45 Re: json functions
Previous Message Jashaswee 2013-06-19 10:51:43 postgresql query