SQL Exercises: How many customers get a grade for their performance
SQL Aggregate Functions: Exercise-5 with Solution
From the following table, write a SQL query to determine the number of customers who received at least one grade for their activity.
Sample table: customer
Sample Solution:
SELECT COUNT (ALL grade)
FROM customer;
Output of the Query:
count 7
Code Explanation:
The said SQL statement is used to count the total number of grades present in the 'customer' table. The "COUNT" function is used to count the number of non-null values in the specified column, in this case, the "grade" column.
The "ALL" keyword is not necessary as it is the default behavior for the "COUNT" function to count all values, including duplicates.
Explanation:
visual presentation:

Practice Online
Query Visualization:
Duration:

Rows:

Cost:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: Find number of customers have listed their names.
Next SQL Exercise: Find the maximum purchase amount of all the orders.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
SQL: Tips of the Day
What is the best way to paginate results in SQL Server?
SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, * FROM Orders WHERE OrderDate >= '1980-01-01' ) AS RowConstrainedResult WHERE RowNum >= 1 AND RowNum < 20 ORDER BY RowNum
Database: SQL Server
Ref: https://bit.ly/3MGrNlk
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook