반응형
You are given a table with the following format:
** encryption table schema **
- md5
- sha1
- sha256
Problem is the table looks so unbalanced - the sha256 column contains much longer strings. You need to balance things up. Add '1' to the end of the md5 addresses as many times as you need to to make them the same length as those in the sha256 column. Add '0' to the beginning of the sha1 values to achieve the same result.
Return as:
** output table schema **
- md5
- sha1
- sha256
Solution:
SELECT
RPAD(md5, LENGTH(sha256),'1') AS md5,
LPAD(sha1, LENGTH(sha256), '0') AS sha1,
sha256
FROM
encryption
Result:
md5 | sha1 | sha256 |
2fb8ef75c96f669bfc7409eb09b0987f11111111111111111111111111111111 | 000000000000000000000000ab7a651e7f20b66e84fefc785941727250eb6c37 | 30f7a59bfe25d47a0edbb330c556502c5aa6ca771d8a65776c12f3beee80f4b9 |
f3d2d7bec379fbd23eb4658d35b93f7211111111111111111111111111111111 | 000000000000000000000000ccd512990187d8a212a43ec06af712935bf7cd84 | ee9729a138b001a9f0d1d623db58ef8b39df89df0609c07821fb1b70106bca90 |
5ceb0e13d80eb7343e5bb66f4121790a11111111111111111111111111111111 | 0000000000000000000000007519474b1954c2e4e04d6a3afc63ec05c8070f44 | 26e06160bbf5e0057d9b252a62bd5e3d7fb2c8325c5a8965246b8e10daa90fc3 |
1ecd061670f0fc89ef627a57826a05fa11111111111111111111111111111111 | 00000000000000000000000020bf3c9d5c5394beb34d85cb0ce61267e29fe5cf | 87cad197a6b50c0ab068162c5472313b2b24f9f1ad81b03ad5f9c571dcd20d7b |
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
SQL: Disorder (0) | 2022.06.25 |
---|---|
Adults only (SQL for Beginners #1) (0) | 2022.06.25 |
Sum of angles (0) | 2022.06.22 |
SQL Basics: Up and Down (0) | 2022.06.21 |
GROCERY STORE: Inventory (0) | 2022.06.20 |