I am trying to calculate a rate over time. I have two distinct tables in my database and need quantities from both tables. Here is what I have so far which is not working:
SELECT ROUND(my_count/cumulative_amount*1000000,2) FROM
(SELECT SUM(val1) as my_count, fiscalMonth from tableA where flag=1 and fiscal_year=2013
group by fiscalMonth
order by fiscalMonth),
(SELECT SUM(SUM(amount)) OVER
(ORDER BY fiscalMonth ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS
cumulative_amount from tableB where fiscalYear = 2013
group by fiscalmonth,
order by fiscalmonth)
Each of the queries running against Table A and Table B give the correct result. How do I do the calculation?
Thanks and I hope this makes sense.