>>Hi All,
>> I have need of a select statement that adds certain values and returns a single record out of, for example, two records.
>>
>>
1 GLOC 20228 9.33247 1.10 92.16 1 T P 1
>> 2 GLOC 17533 5.00000 1.10 92.16 1 T P 2
>>
>>The select statement would preferably return
>>
>>
1 GLOC 20228 14.33247 1.10 92.16 1 T P 1
>>
>>I guess what I am saying is that I want to add one value out of one record to the other value in the first. Does anyone have any ideas?
>>Thanks,
>
>Win if I understand you right you want to :
>1) Sum some fields
>2) Get first record of some key (GLOC here)
>
>Aggregate functions by nature always get the last entry for non-aggregate fields. Therefore first you should take the table upside down then sum :
>
>
select * from myTable ;
> order by GLOCField descending ;
> into cursor UpSideDown ;
> nofilter
>
>select *, sum(SumField) as TotSomething ;
> from UpSideDown ;
> group by GLOCField ;
> into cursor mySum
>
>PS: If the record you want to get with same key had something like being max() of that group then you could do that in one SQL.
>Cetin
Hilmar & Cetin,
Thanks for your replys. I think I am on the right track now.
Winn Pauley