Shortest Distance | Advanced SQL Interview Questions | Data Engineer Interview Question | FAANG SQL

Опубликовано: 14 Март 2026
на канале: Grow with Data
343
14

Video 345: This is the 29th video of the SQL Interview Question series.

00:00 - Introduction to dataset and Question
02:00 - Approach 1: Using Self Join
08:00 - Approach 2: Using Windows Function
11:30 - Conclusion

We are given Point table which stores the position of a point on the x-axis
Its the primary key for the table and won't get repeated, means no two points repeat in this table

We are asked to find the shortest distance between any two points from the Point table

In this video, we'll explore three different SQL approaches to solve this problem:

** Approach 1: Self Join **
This method involves performing a self join on the Point table to calculate the absolute differences between all pairs of points.

** Approach 2: Using Window Functions **
Here, we sort the points and use window functions to calculate the differences between adjacent points, making it efficient and straightforward.

Each approach provides a unique way to identify the shortest distance between points, showcasing various SQL techniques and their applications.

For a comprehensive understanding of these SQL methodologies and their application, please refer to this explanatory video.

code: https://github.com/jeganpillai/adv_sq...

Follow me on,
Website : https://growwithdata.co/
YouTube :    / @growwithdata  
TikTok :   / growwithdata  
LinkedIn :   / growwithdata  
Facebook :   / growwithdata.co  
FB Group : facebook.com/groups/datainterviewpreparation
twitter :   / growwithdata_co  
Instagram :   / growwithdata.co  
WhatsApp : https://whatsapp.com/channel/0029VaF8...
TheWide : https://thewide.com/profile/891

#sql #dataengineers #tablejoins #ceil #floor #bucket #meta #google #facebook #apple #paypal #netflix #amazon #deinterview #sqlinterview #interviewquestions #leetcode #faang #maanga #mysql #oracle #dbms #query #sqlserver #mysql #coderpad #aggregates #aggregation #nonaggregation #database #placementpreparation #lead #lag #windowsfunction #nullcheck #coalesce #sqlperformance #ifnull #case #lead #lag #windowsfunction #tamil #tamilpython #tamilinterview #tamilinterviewlatest #tamilinterviewquestions #sqlintamil