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.
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.
Syntax:
Select count(salary) from emp;
Syntax:
Select count(distinct salary) from emp;
See Also:
Database
Tables
Alter Command
Update Command
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 Function with where clause |
Count (column_name)
In this, all the rows counted except null values but counted 0 value.
Select count(salary) from emp;
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 |
See Also:
Database
Tables
Alter Command
Update Command
No comments:
Post a Comment