What is a sub-query? When would you use one?

Answers were Sorted based on User's Feedback



What is a sub-query? When would you use one?..

Answer / mkd

A subquery is a SELECT statement that is nested within
another T-SQL statement. A subquery SELECT statement if
executed independently of the T-SQL statement, in which it
is nested, will return a result set. Meaning a subquery
SELECT statement can standalone and is not depended on the
statement in which it is nested.

Sometimes the criteria for determining which set of records
will be affected by a SELECT, UPDATE, DELETE and/or INSERT
statement cannot be obtained by hard coding the selection
criteria. Occasionally there is a need to use the results
of a SELECT statement to help determine which records are
returned or are affected by a T-SQL statement. When a
SELECT statement is used inside another statement, the
inside SELECT statement is known as a subquery.

Is This Answer Correct ?    13 Yes 0 No

What is a sub-query? When would you use one?..

Answer / c suresh kumar

sub query is part of main query.this useful we retrive data
from the another table.

Is This Answer Correct ?    2 Yes 0 No

What is a sub-query? When would you use one?..

Answer / swapna

Subquery is used to get information from a table based on
unknown conditions.
If select stmt not perform entire task using
selection,projection,and joins then we can perform that
type of task using sub queries.

Is This Answer Correct ?    3 Yes 8 No

Post New Answer

More SQL Server Interview Questions

Can you tell me the difference between DELETE & TRUNCATE commands?

15 Answers  


How to select some specific rows from a table in ms sql server?

0 Answers  


How to write query to Delete the records in child table and corresponding records in parent table

11 Answers   Semantic Space,


What is difference between equi join and natural join?

0 Answers  


How do I clean up sql server transaction log?

0 Answers  






What is sql profiler. What are the default templates with it? : sql server database administration

0 Answers  


CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType varchar(50) ) go create trigger hpms_create_Insert on HPMS_CompetencyTypes for insert as if Exists ( select * from [HPMS_CompetencyTypes] where CompetencyType=(select * from [HPMS_CompetencyTypes])) begin Rollback tran Raiserror ('duplicate value',12,6) go insert HPMS_CompetencyTypes (CompetencyType) values ('new') I'm new to trigger can any one tell me where is the issue. Please.

2 Answers  


Explain what is lock escalation and what is its purpose?

0 Answers  


What is a View ? Can we insert, Update and delete a view?

0 Answers   Arigo Infotech,


What do you mean by subquery?

0 Answers  


What do you mean by data manipulation language?

0 Answers  


Explain how to integrate the ssrs reports in application?

0 Answers  


Categories