Given Database Schema:
[The primary key for the tables is mentioned in bold)
account(**account\_no** , branch\_name,balance)
depositor(customer\_name,account\_number) {No key was stated here}
customer(**customer\_name**,customer\_street,customer\_city)

The question required to write the SQL query for - Find average balance for each customer who lives in Harrison and has atleast 3 accounts.

I wrote the following SQL query:

```
select depositor.customer_name,avg(balance)
from depositor,account,customer
where depositor.account_number=account.account_number and
          depositor.customer_name=customer.customer_name  and
          customer_city='Harrison'
group by depositor.customer_name
having count(depositor.account_number) >=3

```

My textbook mentions of the query as:

```
select depositor.customer_name,avg(balance)
from depositor,account,customer
where depositor.account_number=account.account_number and
          depositor.customer_name=customer.customer_name  and
          customer_city='Harrison'
group by depositor.customer_name
having count( distinct depositor.account_number) >=3

```

Would placing distinct here lead to a change in result ?
 According to my analysis, The cross-product of the resultant relation (depositor*account*customer) will have the candidate key as 
 **customer\_name account\_number** so distinct would not add any value here.