Kata SQL
SQL Basics — Position
Published in
1 min readOct 3, 2020
You have access to a table of monsters as follows:
monsters schema
- id
- name
- legs
- arms
- characteristics
In each row, the characteristic column has a single comma. Your job is to find it using position(). You must return a table with the format as follows:
output schema
- id
- name
- comma
The comma column will contain the position of the comma within the characteristics string. Order the results by comma.
Hint: The syntax of “POSITION” is
position(',' in characteristics)
Solution:
select id, name, position(',' in characteristics) as comma from monsters order by comma;