I was solving this Leetcode question(1173. Immediate Food Delivery I) and I am kinda confused on why I am not getting the right answer when using COUNT(). but when I use SUM(), I am getting the right answer. I specify a condition for both SUM and COUNT and from my understanding, they should both be adding or counting when order\_date=customer\_pref\_delivery\_date, is that mean the condition only working for SUM()?

[![enter image description here](https://i.stack.imgur.com/D1IO9.png)](https://i.stack.imgur.com/D1IO9.png)

**Query that return the right answer(33.33):**

```
select round(sum(order_date=customer_pref_delivery_date)/count(delivery_id)*100,2) as immediate_percentage 
from Delivery

```

**Query that return the wrong answer(100.00)**

```
select round(count(order_date=customer_pref_delivery_date)/count(delivery_id)*100,2) as immediate_percentage 
from Delivery

```