Skip to content
Advertisement

Calculate returns and insert into another table

I have a table MF_NAVs which holds daily NAVs of mutual funds. I want to calculate the absolute returns over 1 day, 7 day, 15 days, 1 month, 3 month, 6 month, 1 year, 3 year, 5 year & since inception. And then INSERT the calculated values into another table MF_Returns.

The table structure and sample data for MF_NAVs is given below. I have also created a fiddle at the following link : https://www.db-fiddle.com/f/fYam96yYZo5tQLGLtcbhaQ/1

I use the SELECT query given below to calculate the absolute returns. The result from this query is also given below. My problem is I’m unable to save the result of this query into the MF_RETURNS table [structure given below].

The MF_NAVs table has around 20k different SchemeCode. Each SchemeCode has NAVs for different periods ranging from past few days to several months.

Please help save the calculated returns into MF_Returns table.

Query to calculate returns:

Table Structure : MF_NAVs

Sample Data: MF_NAVs

Table Structure : MF_RETURNS

Query Output

Advertisement

Answer

ONLY TEMP SAMPLE. I will correct it after some questions are cleared.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement