본문 바로가기
Data Analysis/SQL

[SQL] 20. Hacker_Rank Advanced Certificates - A number of algorithms are used to mine cryptocurrencies. As part of a comparison, create a query to return a list of algorithms and their volumes for each quarter of the year 2020.

by Hagrid 2023. 1. 25.
반응형

https://www.hackerrank.com/certificates/iframe/8e57e6090694

 

HackerRank

Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews.

www.hackerrank.com

 

 

SELECT sender,
       Min(dt)     AS sequence_start,
       Max(dt)     AS sequence_end,
       Count(*)    AS transactions_count,
       Sum(amount) AS transactions_sum
FROM   transactions
WHERE  sender = recipient
       AND dt BETWEEN Dateadd(hour, -1, Min(dt)) AND Max(dt)
GROUP  BY sender,
          sequence_start,
          sequence_end
HAVING Count(*) >= 2
       AND Sum(amount) >= 150
ORDER  BY sender ASC,
          sequence_start ASC,
          sequence_end ASC;
          
          
          
          
          
          
SELECT sender,
       Min(dt)     AS sequence_start,
       Max(dt)     AS sequence_end,
       Count(*)    AS transactions_count,
       Sum(amount) AS transactions_sum
FROM   transactions
WHERE  sender = recipient
       AND dt BETWEEN Dateadd(hour, -1, Min(dt)) AND Max(dt)
GROUP  BY sender,
          sequence_start,
          sequence_end
HAVING Count(*) >= 2
       AND Sum(amount) >= 150
ORDER  BY sender ASC,
          sequence_start ASC,
          sequence_end ASC;
반응형

댓글