/*
A cte can be thought as a Temporary results set and
that can be defined within select,insert,update,delete
and views.
Note: the scope of cte is works for within that query only
it can be referenced multiple times in the query
*/
--CTE EXAMPLE
WITH Simplecte(EmpName)
as
(
select EmpName from EmployeeRecord
)
select * from simplecte
uses of CTE:
*it is used to write recursive query
*substitute for a view
*improved readability in case of complex queries
No comments:
Post a Comment