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 the difference between null value, zero, and blank space?
what are date and time intervals? : Sql dba
Can we insert delete data in view?
1. is it possible to use the cursor atttibutes (%found ,% rowcount , %isopen , %notfound ) to our user defined cursor names ....... cursor cursor_name is select * from scott.emp if you use... cursor_name%found , %rowcount ,%isopen,%notfound...will it work... -------------------------- 2.what is the difference between the varray and index by table .. -------- 3. type type_name is table of number(8,3) index by binary_integer; identifier_name type_name; first , last , prior , next ,trim are the methods we can use it for the above type...simillary is there any way to apply for cursors... with thanks and regards..sarao...
How is sql used in oracle?
how to create a new view in mysql? : Sql dba
How do I remove duplicates in two columns?
What is the max nvarchar size?
What is the difference between sql and mysql?
Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?
What are functions in sql?
Can a table have no primary key?
What mean sql?
what is foreign key? : Sql dba
What is pragma in pl sql?