Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Algorithm
- STR
- 위코드
- slice
- lambda
- enumerate
- MAX
- If
- iNT
- decorator
- len
- and
- WECODE
- 파이썬
- sum
- join
- map
- range
- index
- list
- js
- SQL
- Python
- Sorted
- split
- count
- DART
- LOWER
- FOR
- or
Archives
- Today
- Total
코드로 우주평화
SQL: Right and Left 본문
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 |