Solved HackerRank SQL Challenge: PADS

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

  • graphical user interface, text, application

To view or add a comment, sign in

Explore content categories