"if you encounter any errors in SAP, send me a screenshot at pramod@learntosap.com, and I will help you resolve the issue."

SQL COUNT() Function Explained with Examples | Learn SQL COUNT Clause Easily

SQL TUTORIALS-

SQL COUNT() Function Clause

Introduction-


Trulli Trulli

SQL COUNT() Function Clause

✅COUNT() function returns the number of rows that match a specified condition or are present in a column...


Emoji Examples in HTML

🔸 Example Table: Employees

ID Customer City
1 ANNI DELHI
2 POOJA MUMBAI
3 RAJ PUNE

✅ Example 1: Count All Rows.



SELECT COUNT(*) AS TotalOrders FROM Orders;


Result Show :-

TotalOrders → 3 |


✅ Example 2: Count Non-NULL in a Column.



SELECT COUNT(City) AS CitiesMentioned FROM Orders;


Result Show :-

CitiesMentioned → 3 |


✅ Example 3: Count Orders by City (Use with GROUP BY).



SELECT City, COUNT(*) AS OrdersCount
FROM Orders
GROUP BY City;




Result Show :-

Emoji Examples in HTML

🔸 Example Table: Employees

City OrdersCount
DELHI 1
MUMBAI 1
PUNE 1

✅ Example 4: Count the number of employees in each department.



SELECT Department, COUNT(*) AS TotalEmployees
FROM Employees
GROUP BY Department;


May Be Like Important Link-

-SQL Tutorial for Beginners – Introduction to SQL

-SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause

-SQL SELECT DISTINCT Statement Clause Explained with Examples

-SQL Wildcard Characters: Complete Guide with Examples