Looping with SQL // Very Urgent //
xxxxxx Jan Feb Mar
Orders 10 20 15
Ceased 2 4 3
This would be the input.
The output should resemble
xxxxxx Jan Feb Mar
Output 8 24 36
For every month the total number of orders are counted and subtracted from the ceased orders. Every successful month would hold the cumulative number of orders.
For instance for JAN > the output would be 10 – 2 = 8
But for FEB > (it has to be the output of JAN + the total number of FEB orders) – no. of ceased in FEB
Likewise – this has to be taken for the previous 13 months.
The output given here would be the output – if I run the sql script in APRIL.
Hope I’ve made myself clear.
We have to use only SQL statement to create this output.
[No usage of Procedures or PL/SQL]
The looping has to happen within SQL. Is there ANY way we can get this??
Thanks in advance for all your helps!
- Ramesh
__________________
Ramesh
\"Always Look For Something NEW\"
Last edited by ramesh.kumarm; January 21st, 2009 at 11:22 AM..
|