Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Aways get a 3x3 array from a SQlL select command
Message
From
14/05/2003 10:48:32
 
 
To
14/05/2003 09:03:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00788138
Message ID:
00788186
Views:
17
Sorry I had a typo it shuld have been
   SELECT key, sum(valuea), sun(valueb) from table
        order by key
        where between(date,startdate,enddate)
        into array a
where key are 3 specific stock codes and valuea and valueb are number of items recieved originally and from back orders on specific dates. So what I am trying to get is number of items recieved for each stock code in a give date range. For some some date ranges nothing may have been recieved. SQL select only returns a row when sums are non-zero. So if on key2 has recieved any items in a date range then only 1 row is returned. What I need is an array to has 3 rows and zeros for keys values where nothing is recieed. The best I could think of is to create the a 3x3 matrix with 3 key fields in column1 and zeros for columns 2 and 3 and then add non-zero values to appropriate cells. My question s are:

1. Is this a reasonable approach? If so what is the best method of doing this?
2. Is there a better method? If so what is it?


>>I have a Select command similar to the following
>>
>>      SELECT key, valuea, sun(valueb) from table
>>            order by key
>>            where between(date,startdate,enddate)
>>            into array a
>>
>>My problem is that I can get 1 to 3 rows in the array depending on the data. What I want is to always get 3 rows with zero for non-existant values. For example assume only key2 has a data. I then want the result like
>>
>>        key1    0
>>        key2   12
>>        key3    0
>>
>>What is the best way of doing this?
>
>
>dimension arrRet[3,2]
>arrRet = 0
>for ix=1 to 3
> arrRet[ix,1] = 'key'+trans(ix)
>endfor
>      SELECT key, valuea, sun(valueb) from table ;
>            order by key ;
>            where date between startdate and enddate ;
>            into array arrRet && No grouping - is it sun() or sum() ?
>
>PS: Tweak names.
>
>Update: Forget about above code. Reread your question. What does valuea stand for (thinking it's sum())
>Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform