Solved the “The PADS” SQL Challenge on HackerRank today! This problem was a great combination of string manipulation + aggregation + sorting logic — exactly the kind of thinking required for real-world data analysis 💡 Generate the following two result sets: Query an alphabetically ordered list of all names in OCCUPATIONS, immediately followed by the first letter of each profession as a parenthetical (i.e.: enclosed in parentheses). For example: AnActorName(A), ADoctorName(D), AProfessorName(P), and ASingerName(S). 🔹 Part 1: Formatting Names with Occupations Used CASE along with string concatenation (||) to attach the first letter of each occupation to the name. Example output: 👉 Samantha(D), Julia(A), Maria(P) ✔ Key concepts used: CASE WHEN SUBSTRING / first character extraction String concatenation Query the number of ocurrences of each occupation in OCCUPATIONS. Sort the occurrences in ascending order, and output them in the following format: There are a total of [occupation_count] [occupation]s. where [occupation_count] is the number of occurrences of an occupation in OCCUPATIONS and [occupation] is the lowercase occupation name. If more than one Occupation has the same [occupation_count], they should be ordered alphabetically. Note: There will be at least two entries in the table for each type of occupation. 🔹 Part 2: Counting Occupations Used COUNT(*) with GROUP BY to calculate total occurrences of each occupation and formatted the output into readable sentences. Example: 👉 There are a total of 3 doctors. ✔ Key concepts used: GROUP BY COUNT(*) LOWER() for formatting ORDER BY for sorting results 💡 Learning takeaway: This challenge reinforced how SQL is not just about querying data, but also about presenting it in a meaningful and readable format. Consistency in solving such problems is helping me strengthen my foundation step by step 📊 #SQL #HackerRank #DataAnalytics #LearningJourney #WomenInTech #PracticeMakesPerfect #Upskilling #FutureDataAnalyst
Solved HackerRank SQL Challenge: PADS
More Relevant Posts
-
🚀 Day 20 – Data Analysis Journey | Daily SQL Challenge Continuing my daily SQL practice on HackerRank 💻 🧩 Problem Consider two points: • P₁(a, c) → Minimum LAT_N and Minimum LONG_W • P₂(b, d) → Maximum LAT_N and Maximum LONG_W 👉 Query the Euclidean Distance between these two points and display the result rounded to 4 decimal places. 💡 Approach • Used MIN() and MAX() to find extreme values of LAT_N and LONG_W • Applied the distance formula: √((b - a)² + (d - c)²) • Used POWER() and SQRT() functions to calculate the distance • Rounded the final result to 4 decimal places 🧠 Solution SELECT ROUND( SQRT( POWER(MAX(LAT_N) - MIN(LAT_N), 2) + POWER(MAX(LONG_W) - MIN(LONG_W), 2) ), 4) FROM STATION; ⚠️ Challenge Faced At first, it looked confusing because of the mathematical formula Had to carefully map: 👉 Min & Max values to coordinates 👉 Formula into SQL functions Once broken down step-by-step, it became much clearer ✅ 📚 Key Learning SQL isn’t just about data retrieval it can also handle mathematical computations efficiently. This problem improved my ability to translate formulas into SQL queries. 🔥 Feeling confident solving real-world style problems step by step! #Day20 #30DaysOfSQL #SQL #DataAnalytics #LearningJourney #HackerRank #Consistency #AdvancedSQL 🚀
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on LeetCode — Day 49 of my SQL Journey 💪 Consistency isn’t always visible… But patterns reveal it over time 📈 Today’s problem was about identifying users with persistent behaviour — not just active users, but those who show the same action consistently across days. I worked on analysing behaviour patterns to: • Track user actions across consecutive days • Group continuous activity using ROW_NUMBER() logic • Identify streaks by adjusting date gaps • Filter users with meaningful streak length (≥ 5 days) • Select the strongest pattern per user using RANK() What I practised: • Window functions for streak detection • Handling sequential data with date logic • GROUP BY + HAVING for filtering patterns • Translating consistency into measurable conditions What stood out — Activity can be random… Consistency is never random. When actions repeat over time, They stop being noise and become behaviour. That’s where real insights start. SQL doesn’t just analyse data. It uncovers patterns hidden in time. Consistent learning, one query at a time 🚀 #SQL #LeetCode #SQLPractice #DataAnalytics #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 31 & 32 – SQL Journey: From CTEs to Recursive Queries Over the last two days, I explored how to make SQL queries more structured, readable, and powerful using CTEs and Recursive CTEs. 🔹 What I Learned: 📌 CTEs (Common Table Expressions) • Temporary result sets created using the "WITH" clause • Help break complex queries into simple, step-by-step logic • Improve readability and make queries easier to debug • Replace deeply nested subqueries 📌 Recursive CTEs & Hierarchical Queries • Built using Anchor + Recursive part • Execute repeatedly until a condition is met • Useful for working with structured data like trees and sequences 📌 Hierarchy Concepts Practiced: • START WITH • CONNECT BY PRIOR • LEVEL • SYS_CONNECT_BY_PATH • CONNECT_BY_ROOT 🔹 Hands-on Practice: ✔️ Calculated aggregated results step-by-step using CTEs ✔️ Generated numbers from 1 to N using recursion ✔️ Identified missing values in sequences 🔹 What Changed: Earlier → Writing queries Now → Structuring logic + understanding execution flow step-by-step 💡 Key Insight: CTEs make SQL clean and modular, while recursive queries unlock the ability to work with hierarchical data and patterns — something very common in real-world scenarios. 🔥 Takeaway: Better structure → Better readability → Better problem solving 📈 Learning step by step 🚀 #SQL #CTE #RecursiveCTE #DataAnalytics #LearnSQL #SQLJourney
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on LeetCode — Day 42 of my SQL Journey 💪 Reactions look random… but behaviour usually isn’t 🎯 Today’s problem was about identifying emotionally consistent users — people who tend to react the same way across different content, not just react more. The approach: • Counted total reactions per user and per reaction type • Used a window function inside aggregation to get totals in one pass • Calculated the ratio of the dominant reaction to total reactions • Filtered users where the ratio crossed 60% • Used RANK() to identify the most frequent reaction per user What I practised: • Using window functions inside aggregations • Applying RANK() to capture dominant behaviour • Ratio-based filtering instead of just counts • Translating consistency into a measurable SQL condition What stood out — Consistency isn’t about reacting more… it’s about reacting the same way, repeatedly. Once you frame it as a ratio problem, the pattern becomes clearly visible. That’s where the real insight lies. Also noticed — SQL syntax isn’t universal. Things like ::numeric or QUALIFY don’t work in MySQL. Small difference, but important to keep in mind. Consistent learning, one query at a time 🚀 #SQL #LeetCode #SQLPractice #DataAnalytics #WindowFunctions #LearningInPublic
To view or add a comment, sign in
-
-
📊 Day 63/90 — SQL Learning: Correlated Subqueries Today I explored a slightly tricky but powerful concept: 👉 Correlated Subqueries At first, it felt confusing… but then it clicked 💡 Here’s what I learned: ✅ A correlated subquery runs for each row of the outer query ✅ It depends on values from the main query ✅ Used for row-by-row comparison ✅ More dynamic than normal subqueries --- 🔹 Example: 👉 Find employees earning more than average salary in their department SELECT e.name, e.salary FROM employees e WHERE e.salary > ( SELECT AVG(salary) FROM employees WHERE department = e.department ); --- 💡 Big lesson: Correlated subqueries compare within groups Because: Normal subquery → One result ❌ Correlated subquery → Row-wise logic ✅ --- From today, I’m understanding how to solve real-world grouped problems 📊 💬 Did correlated subqueries confuse you at first? #SQL #DataAnalytics #LearningInPublic #DataAnalystJourney #90DaysChallenge
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on LeetCode — Day 44 of my SQL Journey 💪 IP addresses look structured… but validating them isn’t always simple 🌐 Today’s problem was about identifying invalid IP addresses — not just formatting issues, but logical errors inside each segment. I used string functions and conditional checks to: • Split IP into individual octets using string operations • Validate the number of segments (must be 4) • Check if each octet is within the valid range (0–255) • Detect non-numeric values using pattern matching • Count how often each invalid IP appears What I practised: • Working with string parsing in SQL • Using SUBSTRING_INDEX() for segment extraction • Applying REGEXP for pattern validation • Combining multiple validation rules in one query What stood out — Validation isn’t just about format… it’s about the rules behind the format. A value can look correct, but still logically invalid. That’s where careful checking matters. SQL isn’t just for analysis. It can also enforce data quality. Consistent learning, one query at a time 🚀 #SQL #LeetCode #SQLPractice #DataAnalytics #LearningInPublic
To view or add a comment, sign in
-
-
Learning SQL in 2025? Start here! SQL is like asking questions to a big box of data You type a query, and it gives you the answer. Here's how you can learn step by step: 1 Basics - Learn how to pick data using SELECT, WHERE, ORDER BY, GROUP BY. 2 Filtering - Search only what you need with conditions like IN, BETWEEN. 3 Joins - Combine data from different tables (INNER, LEFT, RIGHT, FULL). 4 Window Functions - Do smart tricks like ranking, finding next/previous values. 5 Dates - Work with time: today, yesterday, months, years. 6 Advanced Stuff - Play with stats, ML tools, and more. 7 CTEs & Subqueries - Break big problems into small easy queries. 8 Speed Tips - Use indexes, don't SELECT *, write clean queries. ✓ How to practice: - Start with small queries. - Use sample data. - Try joins and date functions. - Solve real-world problems. - Do daily practice. SQL is not hard. It's like learning a new language. The more you practice, the better you get! Save this if you're learning SQL or share it with a friend who is. Note: Reposting for new-audience Gif credit: sai kumar #dataanalyst #sql #datascience #dataengineer
To view or add a comment, sign in
-
-
🗓️ SQL Challenge Day #37: Movie Rating 🔹 Solve two tricky ranking problems in one query! 🎬 🔹 Problem: Part 1️⃣: Find user with most ratings (tie-break: lexicographically smaller name) Part 2️⃣: Find movie with highest avg rating in Feb 2020 (tie-break: lexicographically smaller title) 🔹 Solution (UNION ALL): ( SELECT u.name AS results FROM Users u JOIN ( SELECT user_id, COUNT(user_id) AS c FROM MovieRating GROUP BY user_id ) mr ON u.user_id = mr.user_id ORDER BY c DESC, u.name ASC LIMIT 1 ) UNION ALL ( SELECT m.title AS results FROM Movies m JOIN ( SELECT movie_id, AVG(rating) AS r FROM MovieRating WHERE DATE_FORMAT(created_at, '%Y-%m') = '2020-02' GROUP BY movie_id ) mav ON m.movie_id = mav.movie_id ORDER BY r DESC, m.title ASC LIMIT 1 ); ✅ Result: Accepted 💡 Key Takeaway: **UNION ALL + subqueries** cleanly separates two distinct problems! ⚠️ Critical details: - `DATE_FORMAT(created_at, '%Y-%m') = '2020-02'` isolates February - Dual ordering (`c DESC, name ASC`) handles tie-breaks correctly - Parentheses around each SELECT are mandatory for LIMIT in UNION 👇 Your turn: What’s your strategy for handling multi-part SQL problems? Do you always split them like this? #SQL #LeetCode #DataEngineering #ProblemSolving #Coding #LearningInPublic #Database #DataAnalytics
To view or add a comment, sign in
-
-
✅ Solved a SQL problem on StrataScratch — Day 57 of my SQL Journey 💪 Text looks simple… until you try to count words inside it 👀 Today’s challenge: count exact occurrences of specific words — not substrings, but precise matches. The approach: • Normalised text using LOWER() • Used REGEXP with word boundaries (\b) for exact matching • Replaced matches and compared string lengths • Derived counts using length difference logic • Combined results using UNION What I practised: • REGEXP for pattern matching • String manipulation with LENGTH & REPLACE • Handling edge cases like “bull” vs “bullish” • Translating text problems into SQL logic What stood out — Text data looks simple, But precision changes everything. Small variations completely change the meaning. That’s where careful querying matters. SQL isn’t limited to numbers — It can handle text if you think right. Consistent learning, one query at a time 🚀 #SQL #StrataScratch #DataAnalytics #LearningInPublic #SQLPractice
To view or add a comment, sign in
-
-
🚀 Day 39/100 – LeetCode SQL Challenge 🔹 Problem: Find Valid Emails Today’s challenge was about filtering valid email addresses using SQL based on specific rules. 📌 Problem Requirements: Exactly one @ symbol Must end with .com Before @ → only letters, numbers, underscore Domain name → only letters 💡 My Approach: Used REGEXP for pattern matching Defined a strict pattern to validate email format Applied filtering conditions directly in SQL query Sorted the result using ORDER BY user_id 🧠 What I Learned: Difference between LIKE and REGEXP How to write regex patterns in SQL Importance of escaping special characters like . Real-world use of SQL in data validation ⚡ Key Insight: Simple-looking problems can test your understanding of string patterns and edge cases deeply. ✅ Step by step improvement in SQL skills! #Day39 #LeetCode #SQL #DSA #CodingJourney #PlacementPreparation
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development