SQL Day 7 Subquries and Date Functions
SQL Day 7 Subquries and Date Functions
SUBQUERIES
TYPES
* Single row subqueries
* Multi row subqueries
* Multiple subqueries
* Correlated subqueries
MULTIPLE SUBQUERIES
There is no limit on the number of subqueries included in a where clause. It allows
nesting
of a query within a subquery.
CORRELATED SUBQUERIES
A subquery is evaluated once for the entire parent statement where as a correlated
subquery is evaluated once for every row processed by the parent statement
===================================================================================
========================================================
===================================================================================
========================================================
Inline View
From inside select query called inline view.
===================================================================================
========================================================
===================================================================================
========================================================
corelated subquery
Outer query refer inner query value or inner query refer the outer valuse that is
called co related sub query
===================================================================================
========================================================
where class inside select means nested sub query
===================================================================================
========================================================
Date Functions
5. LOCAL TIME STAMP - Our timezone date time and date in the session time zone
Select Localtimestamp from Dual
Select Localtimestamp from Employees
6. DATA BASE TIME ZONE - Wrirtten Difference Between database Time Zone & Local
Time Zone
Select dbtimezone from Dual
Select dbtimezone from Employees
Task:
1,Find out the Employees working dep and the dep names using subquery
2,what if employees layoff next week monday how to find the tenure months
3,Find the employee max salary with details
4,count the employee details who are woking accounts dep using sub query only
5,Find the new year date ?
6,Which weekday next new year will be starts ?