Tutorials

SQL Aggregate Function


SQL COUNT


In Sql, COUNT() function returns the count of number of rows that matches the specified conditions.

 

Syntax for COUNT


SELECT COUNT(column_name)
FROM table_name
WHERE condition;

Example

 

We will use tih_Courses table for demonstration purpose

tih_Courses
Course_ID Course_Name Professor Mode_of_Training
001 .Net Mukesh Tiwari Online and Offline
002 Java Rajneesh Shukla Online and Offline
003 ANSI SQL Rajneesh Shukla Online
004 Basics of Computer Shweta  Online
005 Blogging Tutorial Puja  Online
006 JSP Alok Pandey Online and Offline
007 Servlet Mukesh Tiwari Online and Offline
Query-1: Write a sql query to select total number of courses offered currently.
SELECT COUNT(Course_ID)
FROM tih_Courses

After above sql query gets executed, we will get following result:

COUNT(Course_ID)

7



Please Share this page
Views : 101
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!