반응형
You are given a table named repositories, format as below:
** repositories table schema **
- project
- commits
- contributors
- address
The table shows project names of major cryptocurrencies, their numbers of commits and contributors and also a random donation address ( not linked in any way :) ).
For each row: Return first x characters of the project name where x = commits. Return last y characters of each address where y = contributors.
Return project and address columns only, as follows:
** output table schema **
- project
- address
Case should be maintained.
Solution:
SELECT
LEFT(project, commits) AS project,
RIGHT(address, contributors) AS address
FROM
repositories
Result:
project | address |
ntoLpoh5i | |
E | q6Nnpgg |
D | |
5M | |
Dec | MgK |
Aete | |
I | fz2F1 |
Random | 1Kw7VtrVuc2pez8JmePiQmk5fVGFKqBdDK |
Random | vWR2oU6C56GNtiy |
Random | vGkxufJcESEyM |
Random | 15DuV4dzgaeKN88XKYEnu43FcEwRkTWmgZ |
Random | 14nfG9o8cnUdH7c5W59DvxJhhNN7fwDzyv |
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
SQL: Regex Replace (0) | 2022.07.15 |
---|---|
SQL Basics: Top 10 customers by total payments amount (0) | 2022.07.14 |
SQL Basics - Monsters using CASE (0) | 2022.07.12 |
SQL Basics: Simple NULL handling (0) | 2022.07.11 |
SQL Basics: Simple JOIN and RANK (0) | 2022.07.10 |