• Sorry for delay.

    I have attached two files. One has schema of all the tables used

    & second one contains the SQL query which is body of sproc