Cannot SUM the value of a field

I wonder if someone can help me with this SQL 2016 query.

I have two tables with following data

TblSalesRep This is the table holding the history of the territories that the sales rep looked after and the date range that they looked after it.

TerritoryId SalesRep FromDate ToDate 15 Anne 2020-01-01 2020-06-02 15 Dave 2020-06-03 2020-06-16 15 Anne 2020-06-17 2020-06-22 18 Anne 2020-06-23 2999-12-31

This is the table that holds the sales made by territory

tblSales TerritoryId TransactionId TransactionDate ProductCode Amount 15 1 2020-04-15 Bags 50 15 1 2020-04-15 Bags 50 15 2 2020-06-02 Bag 25 15 3 2020-06-03 Shoes 60 15 4 2020-06-07 Shoes 10 15 5 2020-06-17 Bags 15 15 6 2020-06-18 Bags 25 15 7 2020-06-25 Coat 100 18 8 2020-06-27 Bags 20

I’m trying to produce a report that displays the SalesRep and the total sold between two dates for a given SalesRep.

For example, if I provided a SalesRep = ‘Anne’ and a date range of ‘1 Jun 2020’ to ‘30 Jun 2020’ I would expect a result back of :

SalesRep Sum Anne 185

This is because it should exclude any business sold between 3 Jun 2020 – 16 Jun 2020 as the territory was looked after by Dave for a couple weeks and he sold that business between those dates.

I’ve tried using SUM function whilst joining to TblSalesRep but the figures are not what I’m expecting.

Could someone please assist.