Data Analytics
111K subscribers
225 photos
1 video
2 files
952 links
Perfect channel to learn Data Analytics

Learn SQL, Python, Alteryx, Tableau, Power BI and many more

For Promotions: @coderfun @love_data
Download Telegram
๐—•๐—ผ๐—ผ๐˜€๐˜ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—–๐—ฎ๐—ฟ๐—ฒ๐—ฒ๐—ฟ ๐–๐ข๐ญ๐ก ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ถ๐˜€๐—ฐ๐—ผ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ + ๐—ฆ๐—ต๐—ผ๐˜„๐—ฐ๐—ฎ๐˜€๐—ฒ ๐——๐—ถ๐—ด๐—ถ๐˜๐—ฎ๐—น ๐—•๐—ฎ๐—ฑ๐—ด๐—ฒ๐˜€

๐Ÿ’ซStand out in the job market with globally recognized tech skills

โœ… 100% FREE Learning
โœ… Official Cisco Digital Badges
โœ… Self-Paced Online Courses
โœ… Beginner-Friendly Content
โœ… Hands-on Labs (Selected Courses)
โœ… Globally Recognized Skills

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/4y0ACOI

๐Ÿš€ Start Learning Today. Earn Official Cisco Badges. Get Career Ready!
โค4
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ:
You have 2 minutes to solve this SQL query.
Find the departments where the average salary is greater than the company's overall average salary.

๐— ๐—ฒ: Challenge accepted! ๐Ÿ’ช
SELECT
department,
AVG(salary) AS average_salary
FROM employees
GROUP BY department
HAVING AVG(salary) > (
SELECT AVG(salary)
FROM employees
);

๐Ÿ’ก Explanation:
The query compares each department's average salary with the company's overall average salary.

โ€ข GROUP BY department calculates the average salary for each department.
โ€ข The subquery computes the overall average salary across all employees.
โ€ข HAVING filters only those departments whose average salary exceeds the company average.

This question tests your understanding of:
โœ… GROUP BY
โœ… HAVING
โœ… Aggregate Functions AVG
โœ… Subqueries

๐ŸŽฏ Expected Output Example
Department: Average Salary
IT: 88,500
Finance: 84,000

HR is excluded because its average salary is below the company average.

๐Ÿš€ Alternative Using a Common Table Expression CTE
WITH company_avg AS (
SELECT AVG(salary) AS avg_salary
FROM employees
)
SELECT
department,
AVG(salary) AS average_salary
FROM employees, company_avg
GROUP BY department, company_avg.avg_salary
HAVING AVG(salary) > company_avg.avg_salary;

Using a CTE can improve readability, especially when the same calculated value is reused in larger queries.

๐Ÿš€ Tip for SQL Job Seekers:
Interviewers often ask questions that compare group-level aggregates with overall aggregates. Master the use of HAVING with subqueriesโ€”itโ€™s a key SQL pattern.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค12
๐Ÿš€ ๐—š๐—ผ๐—ผ๐—ด๐—น๐—ฒ ๐—™๐—ฅ๐—˜๐—˜ ๐—”๐—œ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐—ช๐—ถ๐˜๐—ต ๐—–๐—ผ๐—บ๐—ฝ๐—น๐—ฒ๐˜๐—ถ๐—ผ๐—ป ๐—•๐—ฎ๐—ฑ๐—ด๐—ฒ๐˜€ ๐Ÿ”ฅ

Google is offering free AI courses with completion badges to help students & professionals build in-demand AI skills ๐ŸŒ

โœจ Learn from Google Experts
โœจ Earn Google Completion Badges
โœจ Boost Your Resume & LinkedIn Profile
โœจ Build In-Demand AI Skills for 2026

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/49lCYxa

๐Ÿ”ฅ Start your AI journey today and future-proof your career with Google AI learning programs.
โค3
Want to become a pro in Data Analytics and crack interviews?

Focus on these key topics: ๐Ÿ‘‡

1) Understand Data Analytics basics & tools
2) Learn Excel for data cleaning & analysis
3) Master SQL for data querying
4) Study data visualization principles
5) Get hands-on with Power BI/Tableau dashboards
6) Explore statistics & probability fundamentals
7) Learn data wrangling and preprocessing
8) Understand data storytelling and report writing
9) Practice hypothesis testing & A/B testing
10) Get familiar with Python/R for analytics (optional but helpful)
11) Work on real datasets and case studies (Kaggle is great)
12) Build end-to-end projects from data collection to visualization
13) Learn how to communicate insights effectively
14) Practice problem-solving with datasets regularly
15) Optimize your resume with analytics keywords
16) Follow analytics experts and tutorials on YouTube/LinkedIn

Pro tip: Search each topic on YouTube and watch short 10-15 min videos. Practice alongside to build strong fundamentals.

17) Finally, watch full data analytics project walkthroughs and try them yourself.
18) Learn integration of SQL and Power BI/Tableau for advanced reporting.

Credits: https://t.me/sqlspecialist

React โค๏ธ for more
โค17
โ˜๏ธ ๐—ž๐—ถ๐—ฐ๐—ธ๐˜€๐˜๐—ฎ๐—ฟ๐˜ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—”๐—ช๐—ฆ ๐—๐—ผ๐˜‚๐—ฟ๐—ป๐—ฒ๐˜† | ๐—™๐—ฅ๐—˜๐—˜ ๐—”๐—ช๐—ฆ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€๐Ÿš€

โœ”๏ธ High-Demand Cloud Skills
โœ”๏ธ Prepare for AWS Certifications
โœ”๏ธ Strengthen Your Resume & LinkedIn
โœ”๏ธ Unlock Opportunities in Cloud, AI & DevOps

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlinks.in/ed7

๐Ÿš€ Start Learning Today. Build Cloud Skills. Accelerate Your Tech Career!
โค2
I see so many people jump into data analytics, excited by its popularity, only to feel lost or uninterested soon after. I get it, data isnโ€™t for everyone, and thatโ€™s okay.

Data analytics requires a certain spark or say curiosity. You need that drive to dig deeper, to understand why things happen, to explore how data pieces connect to reveal a bigger picture. Without that spark, itโ€™s easy to feel overwhelmed or even bored.

Before diving in, ask yourself, Do I really enjoy solving puzzles? Am I genuinely excited about numbers, patterns, and insights? If youโ€™re curious and love learning, data can be incredibly rewarding. But if itโ€™s just about following a trend, it might not be a fulfilling path for you.

Be honest with yourself. Find your passion, whether itโ€™s in data or somewhere else and invest in something that truly excites you.

Hope this helps you ๐Ÿ˜Š
โค25
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ:
You have 2 minutes to solve this SQL query.
Find the month with the highest total sales.

Assume the table structure: sales(sale_id, sale_date, amount)

๐— ๐—ฒ: Challenge accepted! ๐Ÿ’ช
SELECT
EXTRACT(YEAR FROM sale_date) AS year,
EXTRACT(MONTH FROM sale_date) AS month,
SUM(amount) AS total_sales
FROM sales
GROUP BY
EXTRACT(YEAR FROM sale_date),
EXTRACT(MONTH FROM sale_date)
ORDER BY total_sales DESC
LIMIT 1;

๐Ÿ’ก Explanation:
This query groups sales by year and month, calculates the total sales for each month, and returns the month with the highest sales.

Key parts:
โ€ข EXTRACT YEAR FROM sale_date gets the year.
โ€ข EXTRACT MONTH FROM sale_date gets the month.
โ€ข SUM amount calculates total monthly sales.
โ€ข ORDER BY total_sales DESC sorts from highest to lowest.
โ€ข LIMIT 1 returns the top-performing month.

This question tests your understanding of:
Date Functions, Aggregate Functions SUM, GROUP BY, ORDER BY

๐ŸŽฏ Expected Output Example
Year: 2026, Month: 5, Total Sales: 245,000

๐Ÿš€ Alternative Handles Ties
SELECT
year,
month,
total_sales
FROM (
SELECT
EXTRACT(YEAR FROM sale_date) AS year,
EXTRACT(MONTH FROM sale_date) AS month,
SUM(amount) AS total_sales,
DENSE_RANK() OVER (
ORDER BY SUM(amount) DESC
) AS rnk
FROM sales
GROUP BY
EXTRACT(YEAR FROM sale_date),
EXTRACT(MONTH FROM sale_date)
) ranked
WHERE rnk = 1;

This version returns all months tied for the highest total sales.

๐Ÿš€ Date-based aggregation questions are among the most common in SQL interviews. Practice grouping data by Day, Week, Month, Quarter, Year. You'll encounter these patterns frequently in analytics and reporting roles.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค13
๐ŸŽ“๐Ÿณ ๐—™๐—ฅ๐—˜๐—˜ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ & ๐—Ÿ๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ๐—œ๐—ป ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐Ÿš€

Learn job-ready skills from Microsoft + LinkedIn and add recognized certificates to your resume without spending money

โœ… 100% FREE to access
โœ… Learn from Microsoft + LinkedIn Learning
โœ… Beginner-friendly and career-focused
โœ… Great for students, freshers, and career switchers

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/4wmXdTY

๐Ÿš€ Start learning today. Collect free certifications. Build your skills. Make your resume stand out.
โค2
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ:
You have 2 minutes to solve this SQL query.

Find the customers who placed orders on three or more consecutive days.

Assume the table structure:
orders(order_id, customer_id, order_date)

๐— ๐—ฒ: Challenge accepted! ๐Ÿ’ช

WITH consecutive_orders AS (
SELECT
customer_id,
order_date,
DATE_SUB(
order_date,
INTERVAL ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY order_date
) DAY
) AS grp
FROM (
SELECT DISTINCT
customer_id,
order_date
FROM orders
) t
)
SELECT
customer_id
FROM consecutive_orders
GROUP BY
customer_id,
grp
HAVING COUNT(*) >= 3;

๐Ÿ’ก Explanation:
This query identifies sequences of consecutive order dates for each customer.

โ€ข ROW_NUMBER() assigns a sequence number to each order date per customer.
โ€ข Subtracting the row number from the order date creates the same grp value for consecutive dates.
โ€ข GROUP BY customer_id, grp groups each consecutive streak.
โ€ข **HAVING COUNT(*) >= 3** returns customers with a streak of at least three consecutive days.

๐ŸŽฏ Expected Output Example
Customer ID
101
205

(Customer 101 ordered on June 1, 2, and 3. Customer 205 ordered on July 10, 11, and 12.)

๐Ÿš€ Tip for SQL Job Seekers:
The Gaps and Islands pattern is one of the most advanced and frequently discussed SQL interview topics. Master it for solving:
Consecutive login days, Consecutive purchases, Attendance streaks, Consecutive transactions, User activity analysis

Being comfortable with this pattern can set you apart in technical interviews.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค13
๐ŸŽฏ๐—™๐—ฅ๐—˜๐—˜ ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„ ๐—ฃ๐—ฟ๐—ฒ๐—ฝ๐—ฎ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ | ๐—จ๐—ป๐—น๐—ผ๐—ฐ๐—ธ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—–๐—ฎ๐—ฟ๐—ฒ๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜๐—ฒ๐—ป๐˜๐—ถ๐—ฎ๐—น ๐Ÿš€

โ€” Perfect for students, freshers, and job seekers preparing for placements or their next big opportunity.

โœ… 100% FREE learning resources
โœ… Helps improve interview confidence + job readiness
โœ… Great for placements, internships, off-campus drives, and fresher hiring

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/4fjeMPe

๐Ÿš€ Start learning today. Build confidence. Crack interviews smarter. Move closer to your dream job.
โค6
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ:
You have 2 minutes to solve this SQL query.

Find the customers who placed orders on three or more consecutive days.

Assume the table structure:
orders(order_id, customer_id, order_date)

๐— ๐—ฒ: Challenge accepted! ๐Ÿ’ช

WITH consecutive_orders AS (
SELECT
customer_id,
order_date,
DATE_SUB(
order_date,
INTERVAL ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY order_date
) DAY
) AS grp
FROM (
SELECT DISTINCT
customer_id,
order_date
FROM orders
) t
)
SELECT
customer_id
FROM consecutive_orders
GROUP BY
customer_id,
grp
HAVING COUNT(*) >= 3;

๐Ÿ’ก Explanation:
This query identifies sequences of consecutive order dates for each customer.

โ€ข ROW_NUMBER() assigns a sequence number to each order date per customer.
โ€ข Subtracting the row number from the order date creates the same grp value for consecutive dates.
โ€ข GROUP BY customer_id, grp groups each consecutive streak.
โ€ข **HAVING COUNT(*) >= 3** returns customers with a streak of at least three consecutive days.

This question tests your understanding of: Common Table Expressions (CTEs), Window Functions (ROW_NUMBER()), Gaps and Islands Problem, Date Arithmetic.

๐ŸŽฏ Expected Output Example
Customer ID
101
205

(Customer 101 ordered on June 1, 2, and 3. Customer 205 ordered on July 10, 11, and 12.)

๐Ÿš€ Tip for SQL Job Seekers:
The Gaps and Islands pattern is one of the most advanced and frequently discussed SQL interview topics.

Master it for solving:
โ€ข Consecutive login days
โ€ข Consecutive purchases
โ€ข Attendance streaks
โ€ข Consecutive transactions
โ€ข User activity analysis

Being comfortable with this pattern can set you apart in technical interviews.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค8
๐Ÿ“Š ๐—•๐—ฒ๐˜€๐˜ ๐—ฌ๐—ผ๐˜‚๐—ง๐˜‚๐—ฏ๐—ฒ ๐—–๐—ต๐—ฎ๐—ป๐—ป๐—ฒ๐—น๐˜€ ๐˜๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐——๐—ฎ๐˜๐—ฎ ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ ๐Ÿš€

You donโ€™t need expensive courses to learn SQL, Excel, Python, Power BI, Tableau, and real-world analytics projects.

The Best YouTube channels for Data Analytics can help you build job-ready skills for internships, placements, and full-time analyst roles โ€” all for FREE.

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/3QO3MQB

๐Ÿš€Start with one channel, stay consistent, build projects, and your Data Analytics career can genuinely take off.
โค4
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ: 
You have 2 minutes to solve this SQL query.

Find the product(s) that have never been ordered.

Tables: 
products(product_id, product_name) 
order_details(order_id, product_id, quantity)

๐— ๐—ฒ: Challenge accepted! ๐Ÿ’ช 
SELECT 
    p.product_id, 
    p.product_name 
FROM products p 
LEFT JOIN order_details od 
    ON p.product_id = od.product_id 
WHERE od.product_id IS NULL;

๐Ÿ’ก Explanation: 
This query finds all products that do not have a matching record in the order_details table.

LEFT JOIN returns all products, regardless of whether they've been ordered. Products without matching orders will have NULL values for columns from order_details. WHERE od.product_id IS NULL filters only those products that have never been ordered.

This question tests your understanding of: LEFT JOIN, NULL handling, Finding unmatched records

๐ŸŽฏ Expected Output Example 
Product ID   Product Name 
104   Wireless Mouse 
118   USB Hub 
125   Laptop Stand 

๐Ÿš€ Alternative Using NOT EXISTS 
SELECT 
    p.product_id, 
    p.product_name 
FROM products p 
WHERE NOT EXISTS ( 
    SELECT 1 
    FROM order_details od 
    WHERE od.product_id = p.product_id 
);

NOT EXISTS is often preferred because it handles NULL values correctly and can perform better than other approaches in many database systems.

๐Ÿš€ Tip for SQL Job Seekers: 
Whenever you're asked to find records that don't exist in another table, consider these approaches: 

LEFT JOIN ... IS NULL, NOT EXISTS โœ… (often the best choice), NOT IN (be cautious with NULL values)

Knowing the pros and cons of each approach is a common interview discussion point.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค8
๐Ÿš€ ๐—™๐—ฅ๐—˜๐—˜ ๐—ง๐—–๐—ฆ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป | ๐—•๐—ผ๐—ผ๐˜€๐˜ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—–๐—ฎ๐—ฟ๐—ฒ๐—ฒ๐—ฟ๐ŸŽ“

A FREE TCS certification can be a smart way to strengthen your profile, improve job readiness, and stand out in internships, placements, and fresher hiring.

โœ… Learn from one of Indiaโ€™s top IT companies
โœ… Add a recognized certification to your resume + LinkedIn profile
โœ… Great for students, freshers, and placement preparation
โœ… Free certifications from trusted brands add real value to your profile

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/4fjeMPe

๐ŸŽ“Earn your free TCS certification. Make your resume stronger.
Interviewer:

You have 2 minutes to solve this SQL query. 

Find the employee or employees with the highest salary in the company without using MAX().

Me: Challenge accepted!

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


Explanation:

This query finds the highest-paid employee or employees without using the MAX() aggregate function.

โ€ข DENSE_RANK() ranks salaries in descending order.

โ€ข The highest salary receives a rank of 1.

โ€ข The outer query filters only employees with salary_rank = 1.

โ€ข If multiple employees share the highest salary, they are all returned.

This question tests your understanding of:

โ€ข Window Functions using DENSE_RANK

โ€ข Ranking Data

โ€ข Handling Ties

โ€ข Alternatives to Aggregate Functions

Expected Output Example

Employee: John, Salary: 120,000

Employee: Alice, Salary: 120,000 

Both employees are returned because they share the highest salary.

Alternative Solution using NOT EXISTS

SELECT
    employee_id,
    employee_name,
    salary
FROM employees e1
WHERE NOT EXISTS (
    SELECT 1
    FROM employees e2
    WHERE e2.salary > e1.salary
);


This solution works by returning employees for whom no other employee has a higher salary.

Tip for SQL Job Seekers:

Interviewers often ask you to solve problems without using aggregate functions like MAX() or MIN(). Learn multiple approaches using: 

โ€ข Window Functions 

โ€ข NOT EXISTS 

โ€ข Correlated Subqueries 

โ€ข Self Joins 

Demonstrating alternative solutions shows strong SQL problem-solving skills.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค11
๐—™๐—ฅ๐—˜๐—˜ ๐—ฃ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ด ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ | ๐Ÿฐ ๐— ๐˜‚๐˜€๐˜-๐—ง๐—ฎ๐—ธ๐—ฒ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐Ÿš€

โœ… Python is one of the most beginner-friendly and in-demand programming languages

๐ŸŽ“Perfect For
๐Ÿ‘จโ€๐ŸŽ“ Students
๐Ÿ’ผ Freshers
๐Ÿ’ซCoding Beginners
๐Ÿ“Š Data / AI / Automation aspirants
๐Ÿš€ Anyone planning to start a tech career with Python

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/4wjwEz2

๐Ÿš€ Build Python skills for free. Take your first step toward a stronger tech career.
โค2
Interviewer: 
You have 2 minutes to solve this SQL query. 
Find the employee or employees who earn more than the average salary of their department and have been with the company for more than 5 years.

Assume the table structure: 
employees(employee_id, employee_name, department, salary, joining_date)

Me: Challenge accepted! 

SELECT
    employee_id,
    employee_name,
    department,
    salary,
    joining_date
FROM employees e
WHERE salary > (
    SELECT AVG(salary)
    FROM employees
    WHERE department = e.department
)
AND joining_date <= CURRENT_DATE - INTERVAL '5 years';


Explanation: 
This query applies two conditions to identify experienced, high-performing employees.

โ€ข The correlated subquery calculates the average salary for each employee's department.
โ€ข The first condition returns employees earning above their department's average salary.
โ€ข The second condition filters employees who joined the company more than 5 years ago.
โ€ข Only employees satisfying both conditions are included in the final result.

This question tests your understanding of: 
โ€ข Correlated Subqueries
โ€ข Aggregate Functions using AVG
โ€ข Date Arithmetic
โ€ข Multiple Filtering Conditions

Expected Output Example 
Employee: John, Department: IT, Salary: 95,000, Joining Date: 2018-01-10 

Employee: Sarah, Department: HR, Salary: 82,000, Joining Date: 2017-06-15 

Alternative Using Window Functions 

SELECT
    employee_id,
    employee_name,
    department,
    salary,
    joining_date
FROM (
    SELECT
        *,
        AVG(salary) OVER (PARTITION BY department) AS dept_avg_salary
    FROM employees
) e
WHERE salary > dept_avg_salary
AND joining_date <= CURRENT_DATE - INTERVAL '5 years';


This approach avoids a correlated subquery by calculating the departmental average once using a window function, which can be more efficient on large datasets.

Tip for SQL Job Seekers: 
Real-world interview questions often combine multiple SQL concepts in a single problem. Practice writing queries that use: 
โ€ข Window Functions
โ€ข Correlated Subqueries
โ€ข Date Functions
โ€ข Aggregate Functions
โ€ข Complex WHERE conditions

These combined-concept questions are common in mid-level and senior SQL interviews.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค11
Interviewer: 
You have 2 minutes to solve this SQL query. 

Find the employee(s) with the highest salary in each department without using window functions.

Assume the table structure: 
employees(employee_id, employee_name, department, salary)

Me: Challenge accepted! ๐Ÿ’ช 
SELECT 
    employee_id, 
    employee_name, 
    department, 
    salary 
FROM employees e1 
WHERE salary = ( 
    SELECT MAX(salary) 
    FROM employees e2 
    WHERE e2.department = e1.department 
);

๐Ÿ’ก Explanation: 
This query uses a correlated subquery instead of a window function.

โ€ข The outer query processes each employee
โ€ข The correlated subquery finds the maximum salary within that employee's department
โ€ข If the employee's salary matches the maximum salary, the employee is returned
โ€ข If multiple employees share the highest salary in a department, they are all included

This question tests your understanding of: 
โ€ข Correlated Subqueries
โ€ข Aggregate Functions (MAX)
โ€ข Filtering with Subqueries
โ€ข Handling Ties

๐ŸŽฏ Expected Output Example: 
John     | IT      | 95,000 
Alice    | IT      | 95,000 
Sarah    | HR      | 82,000 
David    | Finance | 91,000 

John and Alice are both returned because they share the highest salary in the IT department.

๐Ÿš€ Alternative Using a Self Join 
SELECT 
    e1.employee_id, 
    e1.employee_name, 
    e1.department, 
    e1.salary 
FROM employees e1 
LEFT JOIN employees e2 
    ON e1.department = e2.department 
   AND e1.salary < e2.salary 
WHERE e2.employee_id IS NULL; 

This solution works by eliminating employees who have someone in the same department with a higher salary. The remaining employees are the highest-paid in their respective departments.

๐Ÿš€ Tip for SQL Job Seekers: 
Interviewers often restrict certain SQL features like window functions or CTEs to evaluate your understanding of alternative approaches. Be prepared to solve the same problem using: 
โ€ข Correlated Subqueries
โ€ข Self Joins
โ€ข CTEs
โ€ข Window Functions

Knowing multiple solutions demonstrates strong SQL fundamentals.

โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค5๐ŸŽ‰4
๐ŸŽ“ ๐—ง๐—ผ๐—ฝ ๐Ÿฑ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐—ง๐—ผ ๐—œ๐—บ๐—ฝ๐—ฟ๐—ผ๐˜ƒ๐—ฒ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—ฆ๐—ธ๐—ถ๐—น๐—น๐˜€๐—ฒ๐˜ ๐Ÿš€

These 5 FREE courses that can help you stand out in interviews and job applications! ๐Ÿ’ผโœจ

๐Ÿ“Š Microsoft Excel
๐Ÿ“ˆ Power BI
๐Ÿ’ซ Python for Data Science
โฐTime Management
๐Ÿ’ฐ Basic Financial Accounting

๐ŸŽฏ Invest a few hours today to unlock better career opportunities tomorrow!

๐Ÿ”— ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜ ๐Ÿ‘‡:-

https://pdlink.in/4dPjz92

๐Ÿ“Œ Save this post and share it with friends looking to upskill in 2026.
โค5๐Ÿ‘1๐Ÿ‘1
๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„๐—ฒ๐—ฟ:
You have 2 minutes to solve this SQL query.

Find the second most recent order placed by each customer.

Assume the table structure:
orders(order_id, customer_id, order_date)

๐— ๐—ฒ: Challenge accepted! ๐Ÿ’ช

SELECT
order_id,
customer_id,
order_date
FROM (
SELECT
order_id,
customer_id,
order_date,
ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY order_date DESC
) AS rn
FROM orders
) ranked
WHERE rn = 2;

๐Ÿ’ก Explanation:

The query assigns a rank to each order based on its order date for every customer.

โ€ข PARTITION BY customer_id creates a separate ranking for each customer
โ€ข ORDER BY order_date DESC ranks the most recent order as 1
โ€ข ROW_NUMBER() ensures each order gets a unique rank
โ€ข The outer query returns only the order with rn = 2, i.e., the second most recent order

This question tests your understanding of:
โœ… Window Functions (ROW_NUMBER)
โœ… Ranking Records
โœ… Partitioning Data
โœ… Top N per Group

๐ŸŽฏ Expected Output Example
Customer ID | Order ID | Order Date
101 | 2056 | 2026-06-15
102 | 2074 | 2026-06-18

Customers with fewer than two orders are automatically excluded.

๐Ÿš€ Alternative Using a Correlated Subquery
SELECT
o1.order_id,
o1.customer_id,
o1.order_date
FROM orders o1
WHERE 1 = (
SELECT COUNT(*)
FROM orders o2
WHERE o2.customer_id = o1.customer_id
AND o2.order_date > o1.order_date
);

This approach counts how many orders are more recent than the current order. If exactly one order is more recent, the current order is the second most recent.

๐Ÿš€ Tip for SQL Job Seekers:
Questions involving the Nth latest or Nth earliest record appear frequently in interviews. Practice solving them using:
โ€ข ROW_NUMBER()
โ€ข RANK()
โ€ข DENSE_RANK()
โ€ข Correlated Subqueries

Understanding when to use each approach is a valuable interview skill.

โค๏ธ React with โค๏ธ for more interview challenges!
โค5๐Ÿ‘3
๐Ÿ“Š ๐——๐—ฎ๐˜๐—ฎ ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐Ÿš€

โœ… 100% FREE learning opportunities
โœ… Great for students, freshers, and beginners
โœ… Help you build a stronger resume with recognized names like Cisco, Google, and Microsoft
โœ… Useful for analytics internships, off-campus drives, and fresher hiring

๐Ÿ”— ๐—˜๐—ป๐—ฟ๐—ผ๐—น๐—น ๐—™๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜๐Ÿ‘‡:

https://pdlink.in/4eRA6eF

๐Ÿš€ Start learning today. Build your analytics foundation. Earn free certifications. Move one step closer to your Data Analyst career.
โค3