Answer the question
In order to leave comments, you need to log in
How to correctly count the number of unique values in a field in a query?
Good afternoon.
There is a table table1 with fields id, name, size.
In the size field, the values are text. You need to count and display the number of unique values.
For example, we have such values as small, medium, large, medium, large, very large. Should get 4 as a result.
I tried with such a construction, but it gives 0.SELECT SUM(DISTINCT size) FROM `table1`;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question