You are on page 1of 16

GROUPING

RECORDS ,JOINS IN SQL


Types of SQL functions
There are mainly two types :
Single Row (or Scalar) functions-it work with a single row at a time.
Multiple Row(or Group or aggregate)Functions-work with data of multiple rows at a time.
Eg: sum(),Avg(),max(),min(),count().

GROUP BY
• GROUP BY Clause combines all those records that have identical values in a particular field
or a group of fields.
• Grouping can done with aggregate functions
Syntax:
SELECT <column name>,aggregate_function
FROM <table name>
GROUP BY <column name>;
Student table
Emp table
Nested Groups -Grouping in multiple columns

To create a group within a group i.e. nested group we need to specify multiple fields in the
GROUP BY expression.
Eg: SELECT deptno,job,count(empno) FROM employee GROUP BY deptno ,job;
Having Clause
Cartesian Product
It is the all possible concatenations formed of all rows of both the tables that is,
when no particular rows and columns are selected. Such operation is also known as
Unrestricted join.It returns n1 x n2 rows.
SELECT * from employee,student123;
Table Aliases
JOIN
Equi-join and Natural join
SYNTAX
NATURAL JOIN

You might also like