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
Why truncate is faster than delete?
Differentiate between % rowtype and type record.
What are the basic techniques of indexing?
How to install oracle sql developer?
What is a unique key and primary key and foreign key?
Can a table contain multiple primary key’s?
what does the t-sql command ident_incr does? : Transact sql
Is it possible to sort a column using a column alias?
What are all ddl commands?
How do I trace sql profiler?
How to connect a sql*plus session to an oracle server?
What is a Mapplet?
Which sorts rows in sql?
What is indexes?
How is use pl and sql?