Joins in SQL
Joins in SQL
1. What are aggregate functions? What is their use? Give some examples.
The function that work on whole records of one column at a time is called aggregate
functions Or in other word Function that works on aggregate of rows. A multiple row
function.
Uses:-An aggregate Function retrieve a single value after performing calculation on set of
values
Example :-
--- (i) Single Row Functions work with a single row at a time. A single row function returns a
--- (ii) Multiple Row or Group Functions work with data of multiple rows at a time and return
aggregated value.
The GROUP BY clause combines all those records that have identical values in a particular
field or a group of fields. This grouping results into one summary record per group if
4. What type of functions can you use with GROUP BY and HAVING clauses?
5. What is the difference between a WHERE clause and a HAVING clause of SQL SELECT
statement?
The difference between WHERE and HAVING clause is that WHERE conditions are applicable
on individual rows whereas HAVING conditions are applicable on groups as formed by
GROUP BY clause.
The HAVING clause places conditions on groups in contrast to WHERE clause that places
conditions on individual rows. While WHERE conditions cannot include aggregate functions,
HAVING conditions can include aggregate functions. Hence, WHERE and HAVING clauses
cannot be used interchangeably in SELECT queries.
A JOIN is a query that combines tuples from more than one table. In a join query, the table
names are given with FROM clause, separated by a comma.
For example,
In this statement, the two tables are emp1 and emp2 from which the column name and
salary are extracted.