Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Last 30 Days
00:00
5 left

SQL for Last 30 Days

EasySQL · PostgreSQL

Problem

Write a basic SQL query to pull all records from the last 30 days that have an active phone number.

Assume the relevant date is activity_date. Include only records dated from 30 days ago through today, with phone_status equal to active and a non-null, non-empty phone_number.

Output

  1. Return all columns from the qualifying records.
  2. Return one row per record, ordered by record_id ascending.

Schema

customer_records
ColumnTypeDescription
record_idPKINTUnique identifier for the record
person_nameVARCHAR(100)Name associated with the record
activity_dateDATEDate of the recorded activity
phone_numberVARCHAR(25)Phone number associated with the record
phone_statusVARCHAR(20)Current status of the phone number
Tablescustomer_records
Interviewer

Your question is SQL for Last 30 Days. Start with the requirements and the one table 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.