Hi Imitiaz,
First of all this calcualtion has nothing to do with database.
How are your count columns defined?
At universe or report?
If at report, than the formula should be like
Total emails sent = count(email_address)
Failed email=count(email address) Where CODE=12
If you are applying the count in universe, just check this
Total emails sent = count(email_address)
Failed email=count(email address) Where CODE=12
The where condition you have applied for failed email will be part of your query, which will effect both.
Also check if the selected date holds the current count.
Thanks
Gaurav