Help with SQL Query

  • I have a query that checks my DB for a entry that has not been updated within 5 days. My problem is this query will only show this file for that one day. I would like to be able to see this file until the field "oneday" is 0

    The way it works now is once  the date is greater than 5 days it no longer shows in the list.

    Can Anyone Help Please

    Here is my query

    SELECT     *, dateupdated AS Expr2, completed AS Expr1

    FROM         dbo.ONSA_NSS

    WHERE     (dateupdated = DATEADD(dd, - 5, { fn CURDATE() })) AND (completed IS NULL) AND (oneday = 1)

     

  • SELECT     *, dateupdated AS Expr2, completed AS Expr1

    FROM         dbo.ONSA_NSS

    WHERE    dateupdated <= DATEADD(dd, - 5,getdate()) /*older or equal than 5 days*/

     AND (completed IS NULL)  /*not completed*/

    AND (oneday = 1) /*oneday??*/

     

    Do you have sample data?

  • Sample data

    Company = ABC

    dateupdated = 03/12/2006 /*Request for a update was sent on*/

    oneday = 1 /*denotes that 5 days ago a request for a updat was sent to this company*/

    Completed = NULL

    Five days later 03/17/2006 the record shows up in a admin list.

    this record should stay in the list until

    1. the Dateupdated is changed

    2 "oneday" is changed to 0 (zero)

    Completed is no longer NULL

    So when a customer updates this file using a web form the Field "oneday" is changed to a 0 (zero)

    This may not happen until tommorow or the day after.

    The query is set to only show files that are 5 days old. and "oneday"= 1

    Tommorow on the 03/18/2006 this record will no longer show in the list

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

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