Yesterday's Question (by Steve Jones): I've got this table and data: CREATE TABLE TheCounts ( intcol INT , charcol CHAR(10) , varcharcol VARCHAR(100) , datecol datetime2 ) GO INSERT TheCounts VALUES (1, 'West', 'Denver Broncos', '2018-01-01') , (2, 'West', 'Oakland Raiders', '2018-01-01') , (3, 'West', 'Los Angeles Chargers', '2018-01-01') , (4, 'West', 'Kansas City Chiefs', '2018-01-01') , (5, 'South', 'Jacksonville Jaguars', NULL) , (5, 'South', NULL, '2018-01-02') , (6, NULL, 'Indianapolis Colts', NULL) , (7, NULL, 'Houston Texans', NULL) , (NULL, 'North', 'Pittsburgh Steelers', NULL) , (NULL, 'North', 'Baltimore Ravens', '2018-01-03') , (NULL, 'North', 'Cincinnati Bengals', NULL) , (NULL, 'North', 'Cleveland Browns', NULL) , (13, 'East', 'Cleveland Browns', '2018-01-04') , (13, 'East', 'Cleveland Browns', '2018-01-04') , (14, 'East', 'Cleveland Browns', '2018-01-04') , (14, NULL, 'Cleveland Browns', NULL) What do I get when running this code? SELECT COUNT(DISTINCT 'North') FROM dbo.TheCounts AS tc Answer: 1 Explanation: The scalar value has no real meaning here with the table. The DISTINCT count of the scalar value is 1. Ref: COUNT() - click here The COUNT Functionin T-SQL - http://www.sqlservercentral.com/articles/T-SQL/142568/ » Discuss this question and answer on the forums |