Hello Shruti_Sagar,
Actually the query contains a where clause which is filtering the defects which are in closed status.
And the exact row is :
"AND BUG.BG_STATUS = 'Closed' "
This will filter only the defects in "Closed" status.
So, may be you have to change it to "Failed".
I hope this helps.