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
- map
- list
- DART
- count
- enumerate
- SQL
- 파이썬
- sum
- split
- Python
- slice
- STR
- LOWER
- WECODE
- If
- decorator
- iNT
- index
- and
- Algorithm
- len
- join
- js
- FOR
- MAX
- 위코드
- lambda
- or
- Sorted
- range
Archives
- Today
- Total
코드로 우주평화
SQL: Regex Replace 본문
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 :) ).
Your job is to remove all numbers in the address column and replace with '!', then return a table in the following format:
** output table schema **
- project
- commits
- contributors
- address
Solution:
SELECT
project,
commits,
contributors,
REGEXP_REPLACE(address ,'[[:digit:]]', '!', 'g') AS address
FROM
repositories
Result:
project | commits | contributors | address |
Bitcoin | 2 | 7 | !!C!Frw!tTJxW!!cShWswpAwbzVbe!!f!y |
Ethereum | 8 | 8 | !J!W!BVPWFQRb!x!PqHq!gPFE!MjWa!!bG |
DASH | 6 | 0 | !ADhovPJrn!a!yCiRTggpwZhpaqfCSXJ!Z |
Monero | 8 | 8 | !!!CVNnEMjemhXw!!R!H!ZKhbiBGC!XSje |
Decent | 7 | 1 | !BWwyPmuRnW!F!J!VPFXQ!!!KzY!!Zrd!N |
Aeternity | 7 | 2 | !DS!cLhKyzF!zPNmM!!HWPhhn!!dxLTuUY |
Reference:
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
Hello SQL World! (0) | 2022.07.17 |
---|---|
GROCERY STORE: Logistic Optimisation (0) | 2022.07.16 |
SQL Basics: Top 10 customers by total payments amount (0) | 2022.07.14 |
SQL: Right and Left (0) | 2022.07.13 |
SQL Basics - Monsters using CASE (0) | 2022.07.12 |