|
Ever have one of those moments where you push send and said doh. Shouldn't have sent that.
I figured it came across wrong. I don't like to just give the answer. I don't like asking for an answer either like I was looking for this week.
I was having same issue, no help on the Internet.
I finally found my answer by experimenting.
Anyway.
Select item, dateofsale, sum(amount)
From fileGroup by rollup (item, dateofsale)
This will give you an amount by item and date along with break totals.
With the group by, you have to explicitly list out the fields. Any field selected without an aggregate function must also be in the group by.
However, you may group by a field that's not in the select list.
You shouldn't put a field that's in a aggregate function in the group by too.
Sent from my iPhone
On Jan 14, 2016, at 12:04 AM, Booth Martin <booth@xxxxxxxxxxxx> wrote:
I plead guilty. At the moment I am a bit angry with myself for not having discovered sql earlier. So far my problems with sql have tended toward my over-thinking the tasks. This group by issue is one more example of a simple answer that I could not find.
The problem I am having with Googling for answers is that I don't know yet how to frame the questions in a way to get answers that relate.
In any event, I do appreciate the courtesy and the answers. Its been pleasing.
On 1/13/2016 5:51 PM, Michael Schutte wrote:--
Booth, from what I remember you were good at what you do! So I'm wondering why you are posting such a simple question.
You need to google "group by clause". Simple search will lead to what you are doing wrong.
I will also recommend googling "group by rollup" clause
Sent from my iPhone
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.