CTE(common table expression)



CTE(common table expression)..

Answer / deepak_shr

A common table expression (CTE) is a temporary result set
that is defined within the execution scope of a single
SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. A
CTE is similar to a derived table in that it is not stored
as an object and lasts only for the duration of the query.
Unlike a derived table, a CTE can be self-referencing and
can be referenced multiple times in the same query.

A CTE can be used to:

1. Create a recursive query.

2. Substitute for a view when the general use of a view is
not required; that is, you do not have to store the
definition in metadata.

3. Reference the resulting table multiple times in the same
statement.

4. Enable grouping by a column that is derived from a scalar
subselect, or a function that is either not deterministic or
has external access.

Is This Answer Correct ?    9 Yes 0 No

Post New Answer

More SQL Server Interview Questions

what's new in sql server 2016?

0 Answers  


whate is advantages of sql server 2000

0 Answers  


Can we rewrite subqueries into simple select statements or with joins? Example?

2 Answers   ASD Lab,


Delete duplicate rows from a table without primary key by using a single query Table Employee empname salary A 200 B 300 A 200 C 400 D 500 D 500 Output should be A 200 B 300 C 400 D 500

14 Answers  


What is raid? : SQL Server Architecture

0 Answers  






If user is owning any SQL Objects, can we drop that user

0 Answers  


How much memory that we are using in Logshipping Concept?

0 Answers  


What is user-defined functions? What are the types of user-defined functions that can be created?

0 Answers  


How do you connect 100 files as a flat file sources in one package of SSIS?

2 Answers  


What are xml indexes?

0 Answers  


What are the character string functions supported by sql server 2005?

0 Answers  


write down the code for "how we delete a table without using of Drop command " ?

7 Answers   CarrizalSoft Technologies, Sonata,


Categories