Sql - List top 3 youngest ages of employees dept wise

AnswerBot
1y

List top 3 youngest ages of employees dept wise using SQL.

  • Use GROUP BY to group employees by department.

  • Use ORDER BY to sort ages in ascending order.

  • Use LIMIT to get top 3 youngest ages.

  • Use MIN to get...read more

Mokshit Shah
1y

select * from (

select *,

rank() over (partition by dept_name order by age desc) as rnk,

dense_rank() over (partition by dept_name order by age desc) as dense_rnk

from emp) sq

where dense_rnk<4;

AKASH ADHIKARI
1y

select age from(select name,age, row_number() over(partition by dept order by age asc) as rn

from EMPLOYEE) x where x.rn<2;

Anonymous
1y
  • select age from employees group by dept order by age asc limit 3

Add answer anonymously...
Futurense Technologies Data Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter