w3resource

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:

Syntax of find the number of customers who gets at least a gradation for his/her performance

visual presentation:

Find the number of customers who gets at least a gradation for his/her performance

Practice Online


Query Visualization:

Duration:

Query visualization of Find the number of customers who gets at least a gradation for his/her performance - Duration

Rows:

Query visualization of Find the number of customers who gets at least a gradation for his/her performance - Rows

Cost:

Query visualization of Find the number of customers who gets at least a gradation for his/her performance - 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.



Follow us on Facebook and Twitter for latest update.

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

 





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