Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Can we create view in stored procedure?

955


How do I use google cloud in sql?

1084


What is the mutating table and constraining table?

1023


Can a key be both primary and foreign?

991


What does desc stand for?

1065


What is update query?

976


In what condition is it good to disable a trigger?

1008


How will you distinguish a global variable with a local variable in pl/sql?

1153


What is difference between group by and partition by?

1055


Which certification is best for sql?

981


Why do we use function in pl sql?

1058


What is the non-clustered index in sql?

1058


Which tcp/ip port does sql server run on? How can it be changed? : Sql dba

999


What are the limitations of sql express?

1066


What is the use of primary key?

1005