Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Trending in AI
Hot
Agentic AI EngineerForward-Deployed EngineerGenAI EngineerAI Architect
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
R and SQL Coding Under Time
00:00
5 left

R and SQL Coding Under Time

MediumSQL · PostgreSQL

Problem

Describe how you would approach a timed coding assessment that includes multiple SQL questions and scenario-based R questions.

For the SQL portion, produce an assessment summary that helps an interviewer evaluate participation, response time, and question-level performance across SQL and R sections.

Output

  1. One row per question in assessment 101, including questions with no responses.
  2. Return question_id, section, question_type, response_count, avg_time_seconds, latest_status, response_rate_pct, type_rank, and prior_avg_time_seconds.
  3. Order by question_id ascending. Rank questions within each question type by response rate descending, then average response time descending.

Output details

  • Use the most recently submitted response per question for latest_status, breaking timestamp ties by greatest response_id; return NULL when absent.
  • Round avg_time_seconds and response_rate_pct to one decimal place, returning NULL average time when no responses exist.
  • Rank with competition ranking, treating tied response rates and average times as equal and placing NULL average times last.
  • Order prior averages by type_rank ascending then question_id ascending, returning NULL for the first question in each type.

Schema

assessment_sessions
ColumnTypeDescription
session_idPKINTCandidate assessment session identifier
assessment_idINTAssessment identifier
candidate_nameVARCHAR(100)Candidate display name
started_atTIMESTAMPSession start timestamp
assessment_questions
ColumnTypeDescription
question_idPKINTQuestion identifier
assessment_idINTAssessment containing the question
sectionVARCHAR(30)Assessment section
question_typeVARCHAR(20)SQL or R question type
difficultyVARCHAR(20)Question difficulty
promptVARCHAR(500)Question prompt summary
candidate_responses
ColumnTypeDescription
response_idPKINTResponse identifier
session_idINTAssessment session identifier
question_idINTQuestion answered
statusVARCHAR(20)Response evaluation status
time_secondsINTTime spent on the response
submitted_atTIMESTAMPResponse submission timestamp
Tablesassessment_sessionsassessment_questionscandidate_responses
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.