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: 
Either your professor made a mistake or you misunderstood what she said. In the context of relational DBMSes, as implemented by various vendors, the aggregate function `COUNT(<expression>)` returns the number of non-NULL values of `<expression>` in the result set (or a group). 

There is a special case of `COUNT(*)`, which returns the number of *rows* in the result set or group, not the number of values of anything. This is equivalent to `COUNT(<constant expression>)`, such as `COUNT(1)`.

Many databases support `COUNT(DISTINCT <expression>)`, which *will* return the number of unique values of `<expression>`.
This is how it works in MS SQL Server

> 
> COUNT(\*) returns the number of items in a group. This includes NULL
>  values and duplicates.
> 
> 
> COUNT(ALL expression) evaluates expression for each row in a group and
>  returns the number of nonnull values. 
> 
> 
> COUNT(DISTINCT expression) evaluates expression for each row in a
>  group and returns the number of unique, nonnull values.
> 
> 
>