SQL Count Distinct
SQL Count (Distinct) Example
Q: How many different movies were Humphrey Bogart and Ingrid Bergman in?
Select Count(Distinct Film_Title) From Thespian_Film_Table Where (Thespian_Last_Name = "Bogart" and Thespian_First_Name = "Humphrey") or (Thespian_Last_Name = "Bergman" and Thespian_Last_Name = "Ingrid");
Note: Humphrey Bogart was in 72 films. Ingrid Bergman was in 40 films. However, the distinct count is 111, not 112 - because both were in Casablanca!
|Sign in to be the first to comment on SQL Count Distinct.|