Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Basic CTEs
Summary
14. Summary

Instruction

Excellent. It's time to wrap things up.

  • The basic syntax for CTEs in SQL Server is:
    WITH CteName1 (Cte1Columns) AS (
      YourCte1
    ),
    CteName2 (Cte2Columns) AS (
      YourCte2
    ),
    ...
    
    SELECT ...
    
  • CTEs are placed at the start of the query. They are introduced with WITH.
  • You can skip column definitions if you provide aliases for columns containing aggregates and other function results.
  • CTEs are temporary sets of rows similar to subqueries. Thanks to them, your query becomes better organized and easier to read.

Shall we start a very short quiz to check how much you remember?

Exercise

Click Next exercise to start the short quiz.