SELECT key, sum(valuea), sun(valueb) from table order by key where between(date,startdate,enddate) into array awhere 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:
>> 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.