SQL Query between dates

If you check my code again i have used isnull function to avoid null values. But i think you haven't used that function in your code thats why you are getting wrong output.

thank you ALL for the help! I solved my issue without the isNull() and added more cases to where i did not want the sum to be counted.