What is a CTE (Common Table Expression), and how is it different from a subquery?
Answer Posted / nashiinformaticssolutions
• CTE: Temporary result set defined using WITH and reusable within the query. Improves readability for complex queries.
• Subquery: Nested query executed each time it is called. Example:
WITH SalesCTE AS (
SELECT employee_id, SUM(sales) AS total_sales
FROM sales
GROUP BY employee_id
)
SELECT * FROM SalesCTE WHERE total_sales > 5000;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is sql not null constraint?
explain the difference between bool, tinyint and bit. : Sql dba
What is the difference between alter trigger and drop trigger statements?
Why do we use cursors?
What is a delimiter in sas?
What is meant by user defined function?
How can use stored procedures in sql?
What is the difference between distinct and unique in sql?
Mention what is the plv (pl/vision) package offers?
Why do we use procedures in pl sql?
What is sql used for?
Define SQL and state the differences between SQL and other conventional programming Languages?
what is the difference between myisam static and myisam dynamic? : Sql dba
What is your daily office routine?
What are the topics in pl sql?