나는 이렇게 학습한다/Algorithm & SQL
Easy SQL: ASCII Converter
daco2020
2022. 5. 31. 23:54
Given a demographics table in the following format:
** demographics table schema **
- id
- name
- birthday
- race
you need to return the same table where all text fields (name & race) are changed to the ascii code of their first byte.
e.g. Verlie = 86 Warren = 87 Horace = 72 Tracy = 84
Solution:
SELECT
id,
ASCII(name) AS name,
birthday,
ASCII(race) AS race
FROM
demographics
Result:
id | name | birthday | race |
1 | 68 | 2000-01-25 | 78 |
2 | 75 | 1978-06-17 | 65 |
3 | 76 | 1966-03-03 | 65 |
4 | 67 | 1963-08-20 | 65 |
5 | 74 | 1961-05-14 | 78 |
6 | 77 | 1974-04-13 | 65 |