Sunday 1 March 2020

Count function in sql | sql count function

Count function in sql | sql count function 


Count Function

It returns number of rows in a table.


How it works

Count(*)

Syntax:

Select count(*) from employee;

It will counted all the rows in a table. If table has no rows, it will return 0.

count(*)
Count(*)

or

Select count(*) from employee where salary>10000 and salary<20000;

It will counted all the rows whose salary is greater than 10000 and less than 20000.


count method in sql
Count Function with where clause


Count (column_name) 

In this, all the rows counted except null values but counted 0 value.

Syntax:

Select count(salary) from emp;



count(salary)
Count function with column name



Count(distinct column-name)

In this, All the rows counted except null values and duplicate values.

Syntax:

Select count(distinct salary) from emp;


count function with distinct keyword
Count function with distinct  keyword



See Also:

Database
Tables
Alter Command
Update Command


No comments:

Post a Comment

Recent Post

Python Project | Banking System | Project on Banking System using python

  PYTHON PROJECT Banking System import csv import pandas as pd import matplotlib.pyplot as plt import sys import datetime found=False def ne...