TGViewer
Data Analyst Interview Resources Data Analyst Interview Resources @dataanalystinterview · 52.6K subscribers
Post #2406 1.12K
🔥 SQL Interview Question of the Day

📌 Scenario:

A company wants to find the highest-paid employee in each department.

You have one table:

employees

• employee_id • employee_name • department • salary

☑ Solution:

SELECT
employee_id,
employee_name,
department,
salary
FROM (
SELECT
*,
DENSE_RANK() OVER (
PARTITION BY department
ORDER BY salary DESC
) AS salary_rank
FROM employees
) e
WHERE salary_rank = 1;

💡 Concept Tested:

Window Functions + DENSE_RANK() (Finding Top Records Within Groups)

❤️ React if you want more SQL interview questions.
  • ❤ 5
More from @dataanalystinterview
  1. Oct 1, 2026🔥 Top 10 Theoretical Interview Questions Every Data Analyst Must Prepare 📊 Data Analyst…
  2. Sep 29, 2026🚀 Excel Formulas Fundamentals — Part 10 📊 Conditional Functions (SUMIF, SUMIFS, COUNTIF,…
  3. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  4. Sep 29, 2026📊 Tableau Learning Roadmap — Part 2 Connecting to Data Before creating visualizations in…
  5. Sep 28, 2026This is useful when you want to guide someone through an analytical narrative. The Tableau…
  6. Sep 28, 2026📊 Tableau Learning Roadmap — Part 1 What is Tableau? Tableau is a Business Intelligence a…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →