Database - Introduction to SQL - Discussion
Discussion Forum : Introduction to SQL - General Questions (Q.No. 32)
32.
A subquery in an SQL SELECT statement:
Discussion:
5 comments Page 1 of 1.
Mohd salman said:
1 decade ago
We use sub query when we're not sure about the condition in the where clause. Ex get list on emp whose salary is greater than min sal using subquery.
select last_name,salary from employees
where salary >
(select min(salary) from employees)
order by last_name;
Here we have used one column only and sorted the result by order by clause and for joins it has a replacement called as correlated subqueries that fetches informations from two tables.
select last_name,salary from employees
where salary >
(select min(salary) from employees)
order by last_name;
Here we have used one column only and sorted the result by order by clause and for joins it has a replacement called as correlated subqueries that fetches informations from two tables.
(1)
Durg said:
1 decade ago
select * from(select * from <table> where <condition>)<alias> order by <alias>
Amol said:
9 years ago
Subqueries use GROUP BY instead of ORDER BY for sorting.
(1)
Gayatri said:
1 decade ago
Please could someone explain the answer. Many thanks.
Amol said:
9 years ago
I think, the last option is also correct.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers