반응형
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 |