Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

CASE WHEN Conditional Filtering

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is CASE WHEN Conditional Filtering. Start with the requirements and the one table on the right.

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.

Problem

Capgemini Invent uses a project intake dashboard to prioritize client requests. Write a PostgreSQL query that derives a decision with CASE WHEN and returns only requests requiring escalation.

Requirements

  1. Classify each request as Exclude, Escalate, Review, or Standard using the stated business rules.
  2. Return only requests classified as Escalate, ordered by request_id.

Use these rules in order:

  • Cancelled requests are Exclude.
  • Active or pending requests with a budget of at least 100000 EUR and a risk score of at least 7 are Escalate.
  • Requests with a budget of at least 50000 EUR or a risk score of at least 5 are Review.
  • All other requests are Standard.

Schema

client_requests
ColumnTypeDescription
request_idPKINTEGERUnique client request identifier
client_nameVARCHAR(100)Client organization name
budget_eurNUMERIC(12,2)Proposed project budget in euros
risk_scoreINTEGERRisk score from 0 to 10
statusVARCHAR(20)Current request status
Tablesclient_requests
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results