Fixing an existing Sql Query

Job ID: 32531445

Budget: £20 – £250 GBP

Hi,

I have a sql query that calculates fees and rebates for trades posted into a database depending on the portfolio ID. This is an old query that has other queries at the start and all work as indented. I'm issues is with the bottom end of the query but i wanted to provide the entire query as it has been created.

There is at the bottom of the query the original section under comments “--Exchange Fees and Rebates for Euribor (Not above because these are volume based)” This is working as intended. I copied the same query and called it “--Exchange Fees and Rebates for Sonia (Not above because these are volume based)” above the original query.

Only changes I had to make was the variables and what products they are looking for. All this seems to work as it picks up the correct trades and enters the table. However, I cannot understand why the calculation for the output is wrong. I know this because they should be negative values and they seems to be posted in positive and of wrong amount.

As I mentioned the original query works for the other products and calculates correctly. Why would this not work as its not any different?

Any help with getting this working would be great. I have attached the snippet I added to the original query.

This is a quick project and more like a support ticket

Thanks
Related categories: Microsoft SQL Server