What is a CTE (Common Table Expression), and how is it different from a subquery?
Answer Posted / glibwaresoftsolutions
• 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
How do I count duplicates in sql?
What is mutating error?
explain the delete statements in sql
how can we destroy the cookie? : Sql dba
Why we use stored procedure instead of query?
what are all types of user defined functions? : Sql dba
What are the commands used in sql?
What is the primary use of normalization?
Mention what pl/sql package consists of?
How do you update f as m and m as f from the below table testtable?
What is set serveroutput on?
Why do we use joins in sql?
What can sql server reporting services do?
What is a constraint?
What is orm in sql?