hi all,
i am facing a very challenging situation and i am not able to write a query.
consider the following data
SELECT 16 num, 17 num2 , 3 num3, 22 num4, 10 num5 FROM dual
UNION ALL
SELECT 9 num, 15 num2 , 21 num3, 2 num4, 24 num5 FROM dual
UNION ALL
SELECT 1 num, 8 num2 , 14 num3, 20 num4, 25 num5 FROM dual
UNION ALL
SELECT 5 num, 6 num2 , 7 num3, 13 num4, 19 num5 FROM dual
UNION ALL
SELECT 18 num, 4 num2 , 5 num3, 11 num4, 12 num5 FROM dual
[http://djmannynyc.com/Capture.JPG] [http://djmannynyc.com/Capture2.JPG] [http://djmannynyc.com/Capture3.JPG]
i am trying to write a query that given two values it will give you summation of the values within a particular bucket.
for example, please see attachments, highlight in yellow.
if value 15 and 19 is given, i want to find the total sum of all values yellow (capture.jpg).
if value 8 and 21 is given, i want to find the total sum of all values in yellow (capture2.jpg)
if value 8 and 14 is given, i want to find the total sum all of values in yellow (capture3.jpg)
basically, when given two values, i draw a square or rectangle from starting number(first number) to end number and sum up all the values
can someone help write a query for such scenario. i heard it can be done with analytic functions but dont know how to use it.
im using oracle 10g and 11g