This content originally appeared on DEV Community and was authored by Vigneswaran Manivannan
*SUB QUERY- *
select min(salary)from staff_details;
2ND MINIMUM-
*Not selecting minimum salary
*
select*from staff_details where salary not in (select min(salary)from staff_details);
*select minimum again to get 2nd minimum
*
select min(salary)from staff_details where salary not in( select min(salary)from staff_details);
*To get the row
*
select*from staff_details where salary=15000; OR
select*from staff_details where salary=( select min(salary)from staff_details where salary not in( select min(salary)from staff_details));
ORDER BY :
to list it as order ( ascending, descending)
select*from staff_details order by salary;
descending;
select*from staff_details order by salary desc;
*LIMIT (Limit the data)- HOW MANY VALUES ( ROW)
*
select*from staff_details order by salary desc limit 2;
*OFFSET- SKIP
*
SKIP THE ROW FROM THE LIST
select*from staff_details order by salary desc limit 2 offset 1;
*GROUP BY
*
It must have aggregate value.
select count(nationality) from staff_details group by nationality;
select nationality, count(nationality) from staff_details group by nationality;
This content originally appeared on DEV Community and was authored by Vigneswaran Manivannan

Vigneswaran Manivannan | Sciencx (2025-06-17T17:07:08+00:00) SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025. Retrieved from https://www.scien.cx/2025/06/17/sub-query-order-bylimit-offset-group-by-17-06-2025/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.