Pergunta de entrevista da empresa Merit Group

Difference between Where and Having Clause ? Types table joins with Examples, And some practical case studies.

Resposta da entrevista

Sigiloso

7 de set. de 2016

Difference between Where and Having Clause : Though both "Where" and "Having" clause are used for filtering purposes,but there is clear difference in its usage. 1. The WHERE clause specifies the criteria for fetching data by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause. 2. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping. 3. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions. Table joins: 1. A SQL JOIN combines records from two tables. 2. A JOIN locates related column values in the two tables. 3. A query can contain zero, one, or multiple JOIN operations. Types of Joins: 1. (INNER) JOIN: Select records that have matching values in both tables. 2. LEFT (OUTER) JOIN: Select records from the first (left-most) table with matching right table records. 3. RIGHT (OUTER) JOIN: Select records from the second (right-most) table with matching left table records. 4. FULL (OUTER) JOIN: Selects all records that match either left or right table records.