Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: Character Count

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

Your question is SQL: Character Count. 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

Discord analytics needs to validate how often a selected character appears in a message. Write a PostgreSQL query that counts the target character in the request with request_id = 1.

The comparison must be case-insensitive, so both uppercase and lowercase occurrences count. Assume target_character contains exactly one character.

Requirements

  1. Return one column named character_count.
  2. Count every case-insensitive occurrence of target_character in message_text.
  3. Restrict the result to the row where request_id = 1.

Schema

character_count_requests
ColumnTypeDescription
request_idPKINTEGERUnique character-count request identifier
message_textTEXTDiscord message whose characters are inspected
target_characterVARCHAR(1)Single character to count case-insensitively
Tablescharacter_count_requests
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results