SQL Practice: Building a Histogram from Raw Activity Data

📊 SQL practice: building a histogram from raw activity data Continuing with DataLemur SQL challenges, I worked on a problem that involved analyzing how employees interact with a database by constructing a histogram of query activity. The goal was to determine how many employees executed N unique queries during a given time window (Q3 2023), including those with zero activity. I approached this in stages:   • filtering query activity within the time window   • counting distinct queries per employee   • and then re-aggregating those results to build the final distribution Using a LEFT JOIN ensured that employees with no activity were included, which is critical when working with real-world datasets where absence of data is meaningful. The solution was accepted ✅, and it reinforced a pattern I’m seeing often:   transforming granular event data into higher-level summaries that can support analysis and decision-making. This type of problem feels very aligned with analytics and data engineering workflows, where building reliable intermediate datasets is just as important as the final result. Thanks to @Nick Singh and the DataLemur team for the continued practice. And as always, I’m very grateful to @Luke Barousse — much of the SQL and PostgreSQL foundation I rely on comes from his teaching:   [https://lnkd.in/dZwd87sd) 15 challenges in, and continuing to focus on writing queries that scale from raw events to structured insights. If you’re also working through SQL interview-style problems, I’ve been using DataLemur — happy to share a referral if useful. #SQL #PostgreSQL #DataEngineering #Analytics #LearningInPublic

  • text

There were commented lines on my previous post, and it's common sense to think that I've been solving these challenges by using AI. In this case, I had to use Claude as a guide only, and I have the full conversation with the model in case anyone would like to take a look at it. I had in my mind what had to be done, the logical steps, but I struggled with some of the syntax and how to wrap up the double aggregation using the two CTEs. I am being honest and true to myself, otherwise I wouldn't even bother posting this content and trying to show that my commitment to learning SQL and slowly making my way to my very first Data Engineering job. I work day in and day out for this target that I set for this year. Thank you all for your support and for taking the time to read my posts, I really appreciate it.

Like
Reply

Muy bien trabajando, felicidades!!

See more comments

To view or add a comment, sign in

Explore content categories