How to calculate previous row value?

352565 pts.
Tags:
SQL Server
SQL Server 2008
SQL Server Functions
Here is the model I am using:

Data:
Date         Hours Worked      FullDay
9/4/2013     7:13:00              No
9/6/2013     10:52:00             Yes
9/7/2013     6:43:00              No
9/10/2013    9:26:00              Yes 


FullDay column to be updated as 'Yes' if previous day worked hours is at least 8 hours. How can I calculate whether or not the previous row value is equal to 8 hours?

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Is there a sequential number to identify the records, or should they just be ordered by date?

    In case not, is it safe to assume that 9/7/2013 is the previous day for 9/10/2013 because there is no record for 9/8 and 9/9?
     
    70,220 pointsBadges:
    report
  • Colin Smith
    If you are using SQL Server 2012 then you can use LAG.


    That should get you what you need if you are using 2012.
    885 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following