Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)
Can anyone tell me what is WITH CTE in SQL?

1 Answer

0 votes
by (119k points)

A CTE (Common Table Expression) is used to define a temporary result set which you can use in a SELECT statement.  It provides a convenient way to manage complicated queries.

CTE is defined within the statement using the WITH operator.  You can define one or more common table expressions like this.

Here is an example of one CTE:

WITH Employee_CTE (EmployeeNumber, Title)

AS

(SELECT NationalIDNumber, JobTitle

 FROM   HumanResources.Employee)

SELECT EmployeeNumber, Title

FROM   Employee_CTE

If you want to learn SQL technical skills, check out this SQL Training course by Intellipaat.

Also, watch this video on SQL to understand more:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
4 answers
asked Feb 27, 2021 in SQL by adhiraj (4k points)
0 votes
1 answer

Browse Categories

...