AS/400 SQL: How can I use a sum() to search for records in a file?
I am trying to use the SQL statement to sum up a total and use the total to compare to another record in the same file. My SQL statement is:
select w1styl,sum(w1actc) from fileA
where w1actc > 0
and sum(w1actc) <=
(select w1remc from filea
where wmactc = 0)
group by w1styl
This sums up the total amount [sum(w1actc)] by STYL and hunts for another record where the sum is less than the remaining amount [w1remc] of another record and nothing in the location [w1actc=0].
The goal is to find multiple locations in a location file that can fit in another location.