본문 바로가기
나는 이렇게 학습한다/Algorithm & SQL

Easy SQL: Absolute Value and Log to Base

by daco2020 2022. 6. 16.

Given the following table 'decimals':

decimals table schema

  • id
  • number1
  • number2

Return a table with two columns (abs, log) where the values in abs are the absolute values of number1 and the values in log are values from number2 in logarithm to base 64.

 

 

Solution:

SELECT 
  ABS(number1), 
  LOG(64, number2)
FROM 
  decimals

 

 

Result:

abs log
2849.529276973034 0.5513855124091469e1
168.16728863472508 0.5318382704916577e1
2637.584645394029 0.5344190335725976e1
1499.4368115919888 0.5411411597784122e1
891.6679278274751 0.5525318604356835e1
878.7178757269603 0.5425574353365518e1

 

 

 

'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글

SQL Basics: Simple table totaling.  (0) 2022.06.18
SQL Basics: Simple IN  (0) 2022.06.17
SQL Basics: Create a FUNCTION  (0) 2022.06.15
SQL with Street Fighter: Total Wins  (0) 2022.06.14
SQL Basics: Simple GROUP BY  (0) 2022.06.13