SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025

*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)fro…


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));

Image description

Image description

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;

Image description

*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;

Image description


This content originally appeared on DEV Community and was authored by Vigneswaran Manivannan


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025." Vigneswaran Manivannan | Sciencx - Tuesday June 17, 2025, https://www.scien.cx/2025/06/17/sub-query-order-bylimit-offset-group-by-17-06-2025/
HARVARD
Vigneswaran Manivannan | Sciencx Tuesday June 17, 2025 » SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025., viewed ,<https://www.scien.cx/2025/06/17/sub-query-order-bylimit-offset-group-by-17-06-2025/>
VANCOUVER
Vigneswaran Manivannan | Sciencx - » SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/06/17/sub-query-order-bylimit-offset-group-by-17-06-2025/
CHICAGO
" » SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025." Vigneswaran Manivannan | Sciencx - Accessed . https://www.scien.cx/2025/06/17/sub-query-order-bylimit-offset-group-by-17-06-2025/
IEEE
" » SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025." Vigneswaran Manivannan | Sciencx [Online]. Available: https://www.scien.cx/2025/06/17/sub-query-order-bylimit-offset-group-by-17-06-2025/. [Accessed: ]
rf:citation
» SUB QUERY, ORDER BY,LIMIT, OFFSET, GROUP BY- 17-06-2025 | Vigneswaran Manivannan | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.