This repository features my solutions for HackerRank Medium/Advanced SQL challenges. The main goal is to practice database querying and ensure data accuracy.
- Query Accuracy: Ensuring precise results using proper JOIN logic without losing data.
- Data Aggregation: Using
GROUP BYandHAVINGcorrectly to prevent data duplication. - Code Readability: Keeping queries clean and adding brief logical notes at the top of each file.
The_PADS.sql- String concatenation, sorting, and aggregate functions.Binary_Tree_Nodes.sql- Hierarchical data classification using conditional statements and Self JOINs.New_Companies.sql- Multi-level JOINs andCOUNT(DISTINCT)across hierarchical tables.Weather_Observation_Station_18.sql- Calculating Manhattan Distance usingABS()and aggregate functions.Weather_Observation_Station_19.sql- Calculating Euclidean Distance usingPOWER()andSQRT().Weather_Observation_Station_20.sql- Calculating the Median value using advanced ranking and window functions.The_Report.sql- Non-equi JOINs (BETWEEN) and conditional sorting based on grade brackets.Top_Competitors.sql- Multi-table JOINs andHAVING COUNTfiltering to identify full scorers.Ollivander's_Inventory.sql- Complex window functions and subqueries to filter minimum power wands.Challenges.sql- AdvancedHAVINGlogic and subqueries to filter maximum and unique counts.Contest_Leaderboard.sql- CombiningMAX()for highest scores andSUM()for total scores across multiple submissions.SQL_Project_Planning.sql- Identifying consecutive dates (Gaps & Islands problem) usingROW_NUMBER().Placements.sql- Comparing values across related rows using Self JOINs and table aliasing.Symmetric_Pairs.sql- Identifying mirrored pairs using Self JOIN andUNIONlogic.Print_Prime_Numbers.sql- Advanced sequence generation and mathematical filtering using Recursive CTE (WITH RECURSIVE) andNOT EXISTS.