How to Write a Subquery Quickly in SELECT Statement

A QUERY WITHIN THE QUERY you can say as a sub Query. In this post, for your benefit, I am sharing ideas on how to write it quickly.

Basically, the main query needs some value from a sub Query. So your inner query should be in a position to supply a value.

Select employee_name
from employee
where dept_no in (100,200);

From the above query, you can understand that the values in the brackets act as a sub Query. Really simple.

Also You May Like: Top Rules You Need to Write a Sub Query

Now the important idea is a sub query should supply a list of values.

Jiddu quotes

Quotes from

Jiddu Krishnamurthi

SUB Query in SELECT statement

Select *
From employee
where dept_no in (
select dept_no
from dept);

You can find here, the idea we already learned. The inner select supplies list of department numbers. For example 100, 200, 300, 400 etc.

That is all. Now you can write any sub query quickly.

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.