0% found this document useful (0 votes)
2K views

Grouping Records, Joins in SQL

Grouping records in SQL allows combining records that have identical values in a particular field or group of fields using aggregate functions like SUM(), AVG(), MAX(), MIN(), and COUNT(). The GROUP BY clause is used to group records and can group on multiple columns to create nested groups. The HAVING clause is used to filter groups. Joins in SQL allow combining data from multiple tables and come in different types like equi-joins that combine rows based on equality comparisons and natural joins that combine common columns.

Uploaded by

V.R. Murugan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Grouping Records, Joins in SQL

Grouping records in SQL allows combining records that have identical values in a particular field or group of fields using aggregate functions like SUM(), AVG(), MAX(), MIN(), and COUNT(). The GROUP BY clause is used to group records and can group on multiple columns to create nested groups. The HAVING clause is used to filter groups. Joins in SQL allow combining data from multiple tables and come in different types like equi-joins that combine rows based on equality comparisons and natural joins that combine common columns.

Uploaded by

V.R. Murugan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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