Re: Need some tips on query generating averages on time series data

From: <ecotaj_at_gmail.com>
Date: Thu, 24 Oct 2013 11:38:27 -0700 (PDT)
Message-ID: <28ff5735-9488-404e-9270-86316f66071b_at_googlegroups.com>


I could do something like

sum((selltime-buytime)*qnt) partition over (...)

However, partitioning over ... is not obvious to me. The reason is that the qnt is different in each trade and so I cannot match the buy and sell orders unless I can somehow shred the rows as such:

orig:

   buytime = T1
   selltime = T2
   qnt = 3
shred:

   row 1:

         buytime = T1
         selltime = T2
         qnt =   1
   row 2:
         buytime = T1
         selltime = T2
         qnt =   1
   row 3:
         buytime = T1
         selltime = T2
         qnt =   1

Any idea how I might transform like this in SQL?

Thank you so much.

Tom Received on Thu Oct 24 2013 - 20:38:27 CEST

Original text of this message