Find out the highest and lowest salaried employee from each dept | Data Engineering Interview | LTI
ฝัง
- เผยแพร่เมื่อ 14 ต.ค. 2024
- If you like this video please do like,share and subscribe my channel.
PySpark playlist : • PySpark and Databricks
PySpark RealTime Scenarios playlist : • PySpark Real Time Scen...
PySpark Interview Question : • PySpark Interview Series
Linkedin : / pritam-saha-060516139
Contact Mail Id : pritamsaha2708@gmail.com
Telegram channel : t.me/Cognitive...
Topmate : topmate.io/pri...
WhatsApp channel : whatsapp.com/c...
Instagram : / pritamsaha627
Travel & Food Vlogs : / @pritamsaha627
1 Subscriber, 1👍🏻, 1Comment = 100 Motivation 🙏🏼
🙏🏻Please Subscribe 🙏🏼
#pyspark #databricks #interview #questions #cognitivecoders
For dataset please join our telegram channel.
t.me/CognitiveCoders
good logic and well explained, thanks
Thanks. Please do like, share and subscribe for supporting us
Nice explanation 👌 👍 👏
Thanks. Please do like, share and subscribe for supporting us.
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""")