What is a CTE (Common Table Expression), and how is it different from a subquery?
Answer Posted / hr@tgksolutions.com
• 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 nvl?
What are the uses of merge?
what happens if null values are involved in expressions? : Sql dba
Differences between Oracle 9i and 10g (Probably in terms of SQL and PL/SQL)?
how to get help information from the server? : Sql dba
what is sql? : Sql dba
What is sql profiler in oracle?
What is primary key in db?
What is #table in sql?
How many unique keys can a table have?
what are local and global variables and their differences? : Sql dba
How many disk partitions should I have?
How to download oracle sql developer?
What is an implicit commit?
What are the 3 modes of parameter?