Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Automating Reporting with SQL/Python
00:00
5 left

Automating Reporting with SQL/Python

MediumSQL · PostgreSQL

Problem

How have you utilized SQL or Python to automate repetitive data extraction or reporting tasks?

For this hands-on version, demonstrate the SQL portion by producing a recurring monthly report from the provided program and work-log data. Include active programs even when they have no qualifying work logs.

Output

  1. One row per active program for January 2025
  2. Columns: program_id, program_name, report_owner, total_approved_hours, approved_entries, and active_log_days
  3. Include only approved logs dated from January 1 through January 31, 2025; show zero totals where no qualifying logs exist
  4. Order by total_approved_hours descending, then program_id ascending

Schema

programs
ColumnTypeDescription
program_idPKINTUnique program identifier
program_nameVARCHAR(100)Program name
statusVARCHAR(20)Current program status
report_ownerVARCHAR(100)Person responsible for the report
work_logs
ColumnTypeDescription
log_idPKINTUnique work-log identifier
program_idINTReferenced program identifier
work_dateDATEDate on which work was recorded
hoursNUMERIC(8,2)Hours recorded for the work log
entry_statusVARCHAR(20)Approval status of the work log
Tablesprogramswork_logs
Interviewer

Your question is Automating Reporting with SQL/Python. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.