Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

String Character Occurrences

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

Your question is String Character Occurrences. Start with the requirements and the two tables 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

FIS PayDirect operations teams inspect message strings when validating payment integration requests. Write a PostgreSQL query that analyzes the text associated with request 101.

Requirements

  1. Join fis_scan_requests to fis_scan_policies and analyze only requests whose policy allows whitespace inspection.
  2. Split the selected string into individual characters, preserving case and counting spaces as characters.
  3. Return one row per distinct character with its occurrence count.
  4. Order results by occurrence count descending, then by the character in ascending order for deterministic output.

Schema

fis_scan_requests
ColumnTypeDescription
request_idPKINTEGERUnique message scan request identifier
policy_idINTEGERPolicy controlling how the message is scanned
input_textTEXTMessage string submitted for character analysis
fis_scan_policies
ColumnTypeDescription
policy_idPKINTEGERUnique scan policy identifier
policy_nameVARCHAR(80)Human-readable policy name
include_whitespaceBOOLEANIndicates whether spaces and other whitespace are included
Tablesfis_scan_requestsfis_scan_policies
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results