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
how do you tune the slow running queries in oracle db , explain the methodology
How do you pronounce sql?
what happens if you no create privilege in a database? : Sql dba
Why do you partition data?
Can we insert in sql function?
How do I get sql certification?
Which data dictionary views have the information on the triggers that are available in the database?
What is meant by temporal data?
what is user defined functions? : Sql dba
What are the basic techniques of indexing?
Mention what are different methods to trace the pl/sql code?
what is the difference between where clause and having clause? : Sql dba
How do you modify a table in sql?
Is sql better than excel?
What are sql triggers used for?