Aggregate Functions
Aggregate Functions
Using GROUP BY clause: Display outputs regarding each group formed by the GROUP BY field.
Without using GROUP BY clause: Display output corresponding to the overall table may or may
GROUP BY: GROUP BY clause is used if statistical records of a table are to be displayed based
on a field. Once the group is formed individual records cannot be accessed in that query. Several
clusters or groups are formed based on the number of different values in the GROUP BY column
For example, if GROUP BY is applied on TYPE field of ITEM table 3 groups are formed – Crops
FROM ITEM
GROUP BY Type;
Cartesian Product
Cartesian product is performed on two tables and it produces all the combination of records in both
If tables A, B have m, n columns and p, q records respectively then resultant table A x B has m+n
SOLUTION 2: SELECT *
FROM EMPL INNER JOIN
DEPT;
SOLUTION 3 : SELECT *
FROM EMPL JOIN
DEPT;
JOIN
NATURAL JOIN: Natural join is a binary operator which works on two tables. They should have
one column which have same name and domain. It a combination of Cartesian product and a where
clause with equality checking on the common columns.
1)Other conditions in that query are ANDed with the join condition.
2) Natural join is mostly done on Foreign key field of one table and Primary key field of
another table.
3) If tables A, B have m, n columns and p, q records respectively then resultant table has m+n
columns and minimum(p,q) records.
EQUI JOIN: Equi join is a join operation which works on the equality condition of values in two
columns from two tables having similar data type. NATURAL JOIN, EQUI JOIN are said to be
INNER JOIN.
Perform Natural Join between these two tables.
SOLUTION 1
SELECT *
FROM EMPL NATURAL JOIN
DEPT;
SOLUTION 2
SELECT *
FROM EMPL, DEPT
WHERE EMPL.DEPT_ID =
DEPT.DEPT_ID;
[RECOMMENDED STATEMENT]