나는 이렇게 학습한다/Algorithm & SQL

Beginner Series #2 Clock

daco2020 2022. 5. 22. 22:55
반응형

Clock shows h hours, m minutes and s seconds after midnight.

Your task is to write a function which returns the time since midnight in milliseconds.

Example:

h = 0
m = 1
s = 1

result = 61000

Input constraints:

  • 0 <= h <= 23
  • 0 <= m <= 59
  • 0 <= s <= 59

 

Solution:

SELECT (h*3600 + m*60 + s)*1000 AS res 
FROM past;

 

Result:

res
61000
3661000
0
3601000
3600000

 

 

반응형

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

SQL Basics: Simple MIN / MAX  (0) 2022.05.24
SQL Basics: Simple JOIN  (0) 2022.05.23
SQL Basics: Simple SUM  (0) 2022.05.21
Returning Strings  (0) 2022.05.20
Even or Odd  (0) 2022.05.19