[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: [sqr-users] Array Sort/Grouping Help
- Subject: Re: [sqr-users] Array Sort/Grouping Help
- From: Darrel Scott <darrel_1977@yahoo.com>
- Date: Thu, 29 Jan 2004 07:02:07 -0800 (PST)
- In-reply-to: <s018d0b9.067@webmail.aflcio.org>
- List-id: This list is for discussion about the SQR database reporting language from Hyperion. <sqr-users.sqrug.org>
George -
First of all let me apologize for the title of this email. I didn't mean for it
to be so vague. I've changed it accordingly.
Secondly, If it was that simple, I wouldn't have posted to this forum :)
What's funny is that I'm already using a GROUP BY expression in my data source
before passing the values in to the array. See below...
-------------------------------------
Begin-Procedure Get-IDs
Begin-Select
a.ID &ID
Move &ID to $ID
Move &ID to #ID
SUM(b.nbr) &NBR
Move &NBR to $NBR
Move &NBR to #NBR
Let #i=0
Do Build-Array
Do Load-Array
FROM TABLE a, TABLE2 b
WHERE a.key = &Key !-- Passed from earlier procedure
AND a.seqnbr IN [$SEQNBR_list] !-- Passed from earlier procedure
AND a.ID = b.ID
group by a.ID
End-Select
End-Procedure
-------------------------------------
Here's the detailed gist...in a nutshell, I grab the KEY from an earlier query.
Using that key I get a list of SEQNBRs. I concatenate those SEQNBRs and pass
them into a list that I inturn use to get the specific IDs that I need. The
problem is that I can get multiple IDs for each KEY. So why can't I use
GROUP-BY logic on the key? Simple - the KEY is unique and will never be the
same. Thus grouping on both the key and ID prevents an accurate list throwing
off the entire SQR.
That's what brings me to this point. Is there a way to get my results from
within my array?
Thanks,
Darrel
George Jansen <GJANSEN@aflcio.org> wrote:
What is your data source? If a relational database, why not write your
SELECT as
SELECT id, sum(nbr) as nbr
FROM whatever
GROUP BY id
>>> darrel_1977@yahoo.com 01/29/04 08:51AM >>>
Hello Fellow SQR'ers...
I'm wondering if anyone out there can assist me.
I'm working with an array with two numeric values (#ID & #NBR) in which
when loaded into the array can look like the output below...
*********************
#ID: 001
#NBR: 123456
#ID: 002
#NBR: 987456
#ID: 003
#NBR: 555444
#ID: 001
#NBR: 000111
*********************
As you can see I have two instances of the #ID variable (which is
expected). Is it possible to sum the #NBR variable for both (or however
many) instances of the #ID and pass that total into a new variable? I
guess I'm looking for a FOR-EACH type of a loop or some type of array
sort, but I've been unable to find any documentation to assist in this
situation.
BTW....my load array logic is below...
---------------------------------------------------
Begin-Procedure Load-Array
Let #Ctr=0
While #Ctr <= #i - 1
If #Ctr > #i - 1
break
End-If
Get #ID #NBR
>From DataArray(#Ctr)
Add 1 to #Ctr
#Debug Show 'ID: '#ID !-- TEST
#Debug Show 'NBR: '#NBR !-- TEST
End-While
Let #ID=0
Let #NBR=0
End-Procedure
---------------------------------------------------
Any assistance would be greatly appreciated.
Thanks,
Darrel
---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users