SQL Exercises: Count the number of different non NULL city values for salesmen
SQL Aggregate Functions: Exercise-19 with Solution
Write a SQL statement that count the number of salesmen for whom a city is specified. Note that there may be spaces or no spaces in the city column if no city is specified.
Sample table: salesman
Sample Solution :
SELECT COUNT(*) FROM salesman WHERE city IS NOT NULL;
Output of the Query:
Note: The pictorial represetation above is based on hypothetical table for the purpose of explanation only. Your answer may not match.
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a SQL statement that counts all orders for a date August 17th, 2012.
Next: Write a query that counts the number of salesmen with their order date and ID registering orders for each day.
What is the difficulty level of this exercise?