This SQL script is designed to analyze the transaction volumes of different cryptocurrency algorithms on a quarterly basis for the year 2020. It uses a common table expression (CTE) to first calculate the total volume for each algorithm per quarter, and then joins this data together to provide a comprehensive view of the transaction volumes throughout the year.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The script first creates a CTE named 'QuarterVolumes' that groups transactions by the algorithm and the quarter of the year, and calculates the sum of the transaction volumes. It then selects from this CTE for each quarter, joining on the algorithm and the quarter number. This results in a table that shows the total transaction volume for each algorithm for each quarter of 2020. The final result is ordered by the algorithm name.
WITH QuarterVolumes AS (
SELECT
C.Algorithm,
Quarter(Dt) AS Quarter,
SUM(Volume) AS V
FROM
coins C
INNER JOIN transactions t ON t.coin_code = C.code
WHERE
Year(Dt) = 2020
GROUP BY
C.Algorithm, Quarter(Dt)
)
SELECT
Q1.Algorithm,
Q1.V AS Q1_v,
Q2.V AS Q2_v,
Q3.V AS Q3_v,
Q4.V AS Q4_v
FROM
QuarterVolumes Q1
LEFT JOIN QuarterVolumes Q2 ON Q1.Algorithm = Q2.Algorithm AND Q2.Quarter = 2
LEFT JOIN QuarterVolumes Q3 ON Q1.Algorithm = Q3.Algorithm AND Q3.Quarter = 3
LEFT JOIN QuarterVolumes Q4 ON Q1.Algorithm = Q4.Algorithm AND Q4.Quarter = 4
WHERE
Q1.Quarter = 1
ORDER BY
Q1.Algorithm ASC;
If you have a HackerRank Certification test or a coding interview coming up, you can use CodeRankGPT to your advantage. It will assist you during your test and help ensure you get the certification or the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.