Select records based on column sum
Posted on 2006-07-11
Need a sql statement where I could specify a value and return only enough records where the quantity satisfies the requirement.
If I needed a quantity of 10 then I would want rows A, B and C (4 + 2 + 5 = 11 which satisfies the requirement of 10).
If I needed a qty of 13 then I would want rows A, B, C and D (4 + 2 + 5 + 5 = 16)
I know I could use a cursor for this but would really like to do this within a single select statement.