Tema: Re: TSQL : skirtumas tarp eilu?
Autorius: netikras
Data: 2010-01-12 11:54:05
MS SQL 2005:

WITH numbered (dt,counter,rowNumber) AS
(
 SELECT dt, counter , ROW_NUMBER() OVER( ORDER BY dt ) AS 'rowNumber'
 FROM YourTable
)
SELECT
 FirstRowSet.dt as 'nuo',
 DATEDIFF( minute, SecondRowSet.dt, FirstRowSet.dt ) / 60 as 'per kiek' ,
 SecondRowSet.counter - FirstRowSet.counter as 'prisukta'
FROM numbered FirstRowSet
JOIN numbered SecondRowSet
 ON FirstRowSet.rowNumber + 1 = SecondRowSet.rowNumber
ORDER BY FirstRowSet.rowNumber;


"bala nemate" <bala.nemate@gmail.com> wrote in message 
news:120ob7hod52wk$.2s8parsv0fqq$.dlg@40tude.net...
> On Tue, 12 Jan 2010 09:33:46 +0200, VyvIT wrote:
>
>> mestelk pvz
>
> dt                  | value
> -----------------------------
> 2009.09.09 12:23:13 | 234
> 2009.09.09 13:23:13 | 239
> 2009.09.09 14:24:13 | 278
>
> ir taip toliau
>
> -- 
> bn/mj
> icq : 171288416
> skype : bala.nemate
> "The blues ain't about making yourself feel better.
> it's about making other people feel worse."
> -- Bleeding Gums Murphy