반응형
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 bit length of the string.
Solution:
SELECT
id,
BIT_LENGTH(name) AS name,
birthday,
BIT_LENGTH(race) AS race
FROM
demographics
Result:
id | name | birthday | race |
1 | 40 | 1983-01-30 | 200 |
2 | 40 | 1974-09-15 | 200 |
3 | 40 | 1962-05-18 | 328 |
4 | 64 | 1971-07-07 | 40 |
5 | 56 | 1991-09-12 | 40 |
6 | 64 | 1961-11-02 | 328 |
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
Remove String Spaces (0) | 2022.06.04 |
---|---|
On the Canadian Border (SQL for Beginners #2) (0) | 2022.06.02 |
Easy SQL: ASCII Converter (0) | 2022.05.31 |
Easy SQL: Rounding Decimals (0) | 2022.05.30 |
Easy SQL: Moving Values (0) | 2022.05.29 |