Question: My professor taught me this SQL statement:

```
SELECT COUNT(length) FROM product

```

will return `2` with the following dataset:

```
product
|id | length | code |
|-------------------|
| 1 |    11  | X00  |
| 2 |    11  | C02  |
| 3 |    40  | A31  |

```

She justified it by saying that `COUNT` doesn't count duplicates. I disagreed. After trying a lot of DBMS, I've never found one that has this behaviour. Does such an DBMS exist?

Answer: 
`COUNT` does count duplicates in all DBMS I'm aware of, but.

> 
> Is there any reason for a professor to teach this behaviour
> 
> 
> 

Yes, there is a reason. In the original relational theory (that underlies all modern relational DBMSes) *relation* is a *set* in mathematical sense of this word. That means that no relation can contain duplicates at all, including all transitional relations, not just your “tables”.

Following this principle you may say that `SELECT length FROM product` already contains only two rows, hence corresponding `COUNT` returns `2`, not `3`.

---

For example, in [Rel](https://reldb.org/c/) DBMS, using the relation given in the question and [Tutorial D](https://en.wikipedia.org/wiki/D_(data_language_specification)) syntax:

```
SUMMARIZE product {length} BY {}: {c := COUNT()}

```

gives:

[![Rel result](https://i.stack.imgur.com/CKNbi.png)](https://i.stack.imgur.com/CKNbi.png)
If the table had looked like this,

```
|   product         |
|id | length | code |
|-------------------|
| 1 |    11  | X00  |
| 2 |    11  | C02  |
| 3 |  null  | A31  |

```

you could expect the query to return 2, at least in Oracle DB, as nulls are not counted. Duplicates are however counted just fine.