I have a table containing the fields Stand, Species, Diameter, TreesPerAcre. I need to retrieve the rows from each Stand where the TreesPerAcre sum to between 20 and 25.
In the following subset only the first five rows should return.
Stand Species Diameter TreesPerAcre
101 DF 48 2
101 NF 27 3
101 DF 24 10
101 DF 22 6
101 PP 18 3
101 DF 16 5
The problem is getting a row-by-row addition to a limit. Using HAVING SUM(TreesPerAcre) BETWEEN 20 AND 25
doesn't work because SUM(TreesPerAcre) for Stand 101 = 29. I surely hope someone has a clue for me.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!