You can use the DISTINCT
keyword within the COUNT
aggregate function:
SELECT COUNT(DISTINCT column_name) AS some_alias FROM table_name
This will count only the distinct values for that column.
More Related Contents:
- How do I (or can I) SELECT DISTINCT on multiple columns?
- SQL/mysql – Select distinct/UNIQUE but return all columns?
- Is there any difference between GROUP BY and DISTINCT
- Group by minimum value in one field while selecting distinct rows
- How to use DISTINCT and ORDER BY in same SELECT statement?
- Eliminating duplicate values based on only one column of the table
- sql query distinct with Row_Number
- MySQL: Select DISTINCT / UNIQUE, but return all columns?
- Huge performance difference when using GROUP BY vs DISTINCT
- Produce DISTINCT values in STRING_AGG
- SQL distinct for 2 fields in a database
- How to select records without duplicate on just one field in SQL?
- Select distinct from multiple fields using sql
- SQL query with distinct and sum
- When do I need to use a semicolon vs a slash in Oracle SQL?
- SQL – HAVING vs. WHERE
- dplyr left_join by less than, greater than condition
- Parse comma-separated string to make IN List of strings in the Where clause
- why is null not equal to null false
- calculate a sum of type time using sql
- What does the “@” symbol do in SQL?
- How to store image in SQL Server database tables column [duplicate]
- Procedure or function !!! has too many arguments specified
- How to efficiently delete rows while NOT using Truncate Table in a 500,000+ rows table
- SQL performance: WHERE vs WHERE(ROW_NUMBER)
- Built-in function to capitalise the first letter of each word
- How do I list all tables in a schema in Oracle SQL?
- oracle sql: update if exists else insert [duplicate]
- What is the meaning of SELECT … FOR XML PATH(‘ ‘),1,1)?
- SQL Sort Order with Null values last