I have a table with symbol, epoch and Volume. The epoch is stored based on Symbol and Epoch in ascending order.

enter image description here

I want to get cumulative volume which is sum of volume and prev timestamp and the volume at current timestamp for the same day and for same symbol.

enter image description here

I am new to SQL and this already seems to be quite complicated. Pls help.

1 Answer 1


Try using over clause. Over Clause Documentation

Select Symbol,
       Sum(Volume)Over(Partition by Symbol,Substring(Epoch,1,6) Order by Epoch) AS CuVol
From YourTableName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.