SQL Basics: math with string manipulations

Valentyn
Oct 4, 2021

Given a demographics table in the following format:

demographics table schema

  • id
  • name
  • birthday
  • race

Return a single column named calculation where the value is the bit length of name, added to the number of characters in race.

Solution

Simple kata on two functions with strings: length and bit_length. They give length of the string and bit length of the string respectively.

SELECT
(length(race) + bit_length(name)) as calculation
FROM
demographics;

--

--