SQL Query - Simple Question

  • Hi guys,

    We got a table in a form like this:

    Imagine it has millions of records! I'm looking for a simple query which fills the '?' mark for 'diffValue' column!

    'diffValue' represents the difference between the value of 'sesSentOctets' of the current row and the previous row (previous minute for the same 'userName'). For instance for the last record, it must result in 140 (1688 - 1548).

    Because we have millions of records, I want a very fast query for that! I know it is solvable by functions or other inner SELECT commands, but they are slow! I want it to be done with just one SELECT if it is possible!

    Many thanks in advance.

  • Duplicate post. All answers in here: http://www.sqlservercentral.com/Forums/Topic1640241-392-1.aspx

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply