SQL Concepts-3
- In this blog we are going to understand some important queries...
- Created new database and tables for solving following queries :
Union :
- Union removes duplicate records from data sets.
- Union first performs sorting operation and then eliminate duplicate records in data sets, after that they return combined data sets.
- Example :
Union All :
- Union All keeps all records from each data sets.
- It also contains duplicate records.
- Example :
Group By :
- Group by is used to group the rows that have same values or it is used to organize similar data into groups.
- Attribute i.e used in aggregate function cannot be in group by statement.
- The attribute used after group by statement and attribute used in aggregate function are only allowed if rather than this another attribute used, it shows error :
- Example :
Order By :
- Subquery is the query within another query and included within WHERE clause.
- The outer query is known as main query and inner query is known as subquery.
- The subquery executes first then it returns result to outer query for condition checking.
- It is easy to understand and slower than join.
- Example :
Correlated subqueries :
- It is used to fetch the outer query value for processing of inner query.
- Again the inner query result is used for outer query processing.
- This continues till matching result is found and then return to main.
- It works like recursion.
- It is used for calculating average.
- Example :
Comments
Post a Comment