Find out the highest and lowest salaried employee from each dept | Data Engineering Interview | LTI

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 7

  • @CognitiveCoders
    @CognitiveCoders  9 месяцев назад

    For dataset please join our telegram channel.
    t.me/CognitiveCoders

  • @krishna-mx1dx
    @krishna-mx1dx 9 месяцев назад

    good logic and well explained, thanks

    • @CognitiveCoders
      @CognitiveCoders  9 месяцев назад

      Thanks. Please do like, share and subscribe for supporting us

  • @sravankumar1767
    @sravankumar1767 10 месяцев назад

    Nice explanation 👌 👍 👏

    • @CognitiveCoders
      @CognitiveCoders  10 месяцев назад

      Thanks. Please do like, share and subscribe for supporting us.

  • @rahuldave6699
    @rahuldave6699 Месяц назад

    query = spark.sql("""with cte as (select dept_id,emp_name,salary, row_number() over(partition by dept_id order by salary desc, emp_name) as rn,
    count(dept_id) over (partition by dept_id order by dept_id) as dept_count from emp
    )
    select dept_id,max(case when rn = 1 then emp_name else Null end ) as max_salary,
    min(case when rn = dept_count then emp_name else Null end) as min_salary
    from cte group by dept_id""")