Re: [NOVICE] group by rollup and cube
От | Laurenz Albe |
---|---|
Тема | Re: [NOVICE] group by rollup and cube |
Дата | |
Msg-id | 1510817247.2639.20.camel@cybertec.at обсуждение исходный текст |
Ответ на | [NOVICE] group by rollup and cube (john snow <ofbizfanster@gmail.com>) |
Список | pgsql-novice |
john snow wrote: > i'm trying to learn how to do these from these examples that i found in: > > https://www.databasejournal.com/features/mssql/using-the-rollup-cube-and-grouping-sets-operators.html > > after modifying the code to run in postgresql 10, i'm finding that even though > i'm getting subtotal and grand total values same as those in the article, > i'm not quite getting the report rows in the desired orders. A query result has no guaranteed ordering unless you specify one with an ORDER BY clause. ORDER BY is executed after the grouping, so you can use it to sort the result rows. You'll have to come up with an ORDER BY clause that puts the result in the desired order. The NULLS LAST clause will help in some of your cases. For example, for your first question I'd use ORDER BY type NULLS LAST to put the summary line at the bottom. Yours, Laurenz Albe -- Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-novice
В списке pgsql-novice по дате отправления: